stc12c5a60s2c语言程序,单片机STC12C5A60S2控制AT24C04的程序(C语言)

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

主芯片:STC12C5A60S2(1T)

工作频率:12.000MHz

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

#include"REG51.H"

#include"INTRINS.H"

typedefunsignedcharBYTE;

typedefunsignedshortWORD;

sbitSCL=P3^4;//AT24C04的时钟

sbitSDA=P3^5;//AT24C04的数据

BYTEBUF[16];//数据缓存区

BYTEcodeTESTDATA[]=

{

0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,

0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF

};

voidDelay5us();

voidDelay5ms();

voidAT24C04_Start();

voidAT24C04_Stop();

voidAT24C04_SenDACK(bitack);

bitAT24C04_RecvACK();

voidAT24C04_SendByte(BYTEdat);

BYTEAT24C04_RecvByte();

voidAT24C04_ReadPage();

voidAT24C04_WritePage();

voidmain()

{

AT24C04_WritePage();

Delay5ms();

你可能感兴趣的:(stc12c5a60s2c语言程序,单片机STC12C5A60S2控制AT24C04的程序(C语言))