12.07.2015 Views

MPLAB® C18 C 编译器函数库

MPLAB® C18 C 编译器函数库

MPLAB® C18 C 编译器函数库

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

硬 件 外 设 函 数2.4.3 使 用 示 例下 面 是 一 个 简 单 的 代 码 示 例 , 该 程 序 举 例 说 明 了 配 置 为 I 2 C 主 通 讯 的 SSP 模 块 , 及 其和 Microchip 24LC01B I 2 C 电 可 擦 除 存 储 器 之 间 的 I 2 C 通 讯 。#include "p18cxx.h"#include "i2c.h"unsigned char arraywr[] = {1,2,3,4,5,6,7,8,0};unsigned char arrayrd[20];//***************************************************void main(void){OpenI2C(MASTER, SLEW_ON);// Initialize I2C moduleSSPADD = 9;//400kHz Baud clock(9) @16MHz//100kHz Baud clock(39) @16MHz}while(1){EEByteWrite(0xA0, 0x30, 0xA5);EEAckPolling(0xA0);EECurrentAddRead(0xA0);EEPageWrite(0xA0, 0x70, arraywr);EEAckPolling(0xA0);EESequentialRead(0xA0, 0x70, arrayrd, 20);EERandomRead(0xA0,0x30);}© 2004 Microchip Technology Inc. DS51297C_CN 第 31 页

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!