AT24C256完整程序文档格式.docx

上传人:b****2 文档编号:5345739 上传时间:2023-05-05 格式:DOCX 页数:9 大小:28.48KB
下载 相关 举报
AT24C256完整程序文档格式.docx_第1页
第1页 / 共9页
AT24C256完整程序文档格式.docx_第2页
第2页 / 共9页
AT24C256完整程序文档格式.docx_第3页
第3页 / 共9页
AT24C256完整程序文档格式.docx_第4页
第4页 / 共9页
AT24C256完整程序文档格式.docx_第5页
第5页 / 共9页
AT24C256完整程序文档格式.docx_第6页
第6页 / 共9页
AT24C256完整程序文档格式.docx_第7页
第7页 / 共9页
AT24C256完整程序文档格式.docx_第8页
第8页 / 共9页
AT24C256完整程序文档格式.docx_第9页
第9页 / 共9页
亲,该文档总共9页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

AT24C256完整程序文档格式.docx

《AT24C256完整程序文档格式.docx》由会员分享,可在线阅读,更多相关《AT24C256完整程序文档格式.docx(9页珍藏版)》请在冰点文库上搜索。

AT24C256完整程序文档格式.docx

sbitISDA=P1^3;

/*****************************************

I2cWait

WaitforsometimetogetproperI2Ctiming

voidI2cWait(void)

{

I2csotp

conditionSDA=0-1whileSCL=1

voidI2cStop(void)

ISDA=0;

I2cWait();

ISCL=1;

ISDA=1;

}

I2cInit

InitializeI2Cinterface

ReleaseI2cBUS

****************************************

voidI2cInit(void)

**/

I2cSentByte

mastertransferdatatoslaveandreturnacknowledgebit

don'

tinclude<

intrins.h>

bitI2cSentByte(unsignedcharbytedata)

unsignedchari;

bitack;

for(i=0;

i<

8;

i++)

{

if(bytedata&

0x80)

else

bytedata<

<

=1;

ISCL=0;

}

ack=ISDA;

returnack;

I2cReceiveByte

slavetrransferdatatomaster

unsignedcharI2cReceiveByte(void)

unsignedcharbytedata=0;

bytedata=bytedata<

1;

if(ISDA==1)

{

bytedata=bytedata|0x01;

}

I2cWait();

returnbytedata;

I2cSendAcknowledge

Mastersendacknowledgebittoslave

acknowledge="

0"

non-acknowledge="

1"

voidSendAcknowledge(bitack)

ISDA=ack;

24c64WriteByte

addr:

0-8192

value:

数据

void_24c64WriteByte(unsignedintaddr,unsignedcharvalue)

I2cStart();

I2cSentByte(0xA0);

I2cSentByte(addr>

>

8);

//送高位地址

I2cSentByte(addr&

0xff);

//送低位地址

I2cSentByte(value);

I2cStop();

delay1ms(15);

24c64WriteMulti

page:

0-255

count:

要写入的数个数

******************************************/

void_24c64WriteMulti(unsignedintpage,unsignedcharcount,unsignedchar*SenBuf)

unsignedintaddr=page*32;

I2cSentByte(0xa0);

0x00ff);

count;

I2cSentByte(SenBuf[i]);

24c64ReadByte

unsignedchar_24c64ReadByte(unsignedintaddr)

unsignedchartemp;

 

I2cSentByte(0xa1);

temp=I2cReceiveByte();

SendAcknowledge

(1);

returntemp;

24c64ReadMulti

0-256,count0-32

要读出的数的个数

void_24c64ReadMulti(unsignedintpage,unsignedcharcount,unsignedchar*RedBuf)

{unsignedintaddr=page*32;

RedBuf[i]=_24c64ReadByte(addr);

addr++;

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 初中教育 > 语文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2