下面的程序是一个时钟程序,当断电时将数据将保存在24c16中。重新上电后先读出24c16中存的数据,之后一直对24c16进行写操作,这样断电就可以保持最后次数据在14c16里面了。
对24c16系列的EEPROM写的过程:起始信号 写器件地址 应答
对24c16系列的EEPROM写的过程:起始信号
#include
#define uchar unsigned char
sbit sda=P2^1;
sbit scl=P2^0;
sbit p1_0=P1^0;
sbit p1_1=P1^1;
sbit p1_2=P1^2;
uchar a,tt;
uchar tem=0;
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay()
{ ;; }
void start()
{
}
void stop()
{
}
void respons()
{
}
void init()//初始化定时器
{
}
void write_byte(uchar date)//写一个字节
{
}
uchar read_byte()//读一个字节
{
}
void delay1(uchar x)
{
}
void write_add(uchar address,uchar date)//写数据的整个过程
{
}
uchar read_add(uchar address))//读数据的整个过程
{
}
void main()
{
}
void zhongd() interrupt 1
{
『本文转载自网络,版权归原作者所有,如有侵权请联系删除』