新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 24C04擴(kuò)展存儲(chǔ)器C和匯編程序

24C04擴(kuò)展存儲(chǔ)器C和匯編程序

作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏
程序功能:統(tǒng)計(jì)單片機(jī)的開(kāi)機(jī)次數(shù)。



#include
#include
#define uint unsigned int
#define uchar unsigned char
sbit sda=P1^1;
sbit scl=P1^0;
uchar temp=0;
uchar data_h,data_l;
uchar state;
const uchar tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void delayic(uint i)
{
uchar j;
while(i--)
{
for(j=0;j<120;j++);
}
}
void delaym(uchar t)
{
uchar i;
for(i=0;i}
void Start_I2c()
{
sda=1;
_nop_();
scl=1;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
sda=0;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
scl=0;
_nop_();
_nop_();
}
void Stop_I2c()
{
sda=0;
_nop_();
scl=1;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
sda=1;
_nop_();
_nop_();
_nop_();
_nop_();
}
void cack(void)
{
sda=0;
_nop_();
_nop_();
_nop_();
scl=1;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
scl=0;
_nop_();
_nop_();
}
void mnack(void)
{
sda=1;
_nop_();
_nop_();
_nop_();
scl=1;
_nop_();
_nop_();
_nop_();
_nop_();
_nop_();
scl=0;
sda=0;
_nop_();
_nop_();
}
void wrbyt(uchar date)
{
uchar i,j;
j=0x80;
for(i=0;i<8;i++)
{
if((date&j)==0)
{
sda=0;
scl=1;
delaym(1);
scl=0;
}
else
{
sda=1;
scl=1;
delaym(1);
scl=0;
sda=0;
}
j=j>>1;
}
}
上一頁(yè) 1 2 下一頁(yè)

評(píng)論


技術(shù)專(zhuān)區(qū)

關(guān)閉