




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/* 1001qq625799961 */*: 24C021 SE5 ON(2-3)SE11EEPROM (2-3)*/*/#include #include #define uint unsigned int#define uchar unsigned char#define _Nop() _nop_()/*/#define sled_dm_port P0 /*LED*/#define sled_wm_port P2 /*LED*/*IIC*/sbit SDA=P34; /*I2C*/sbit SCL=P33; /*I2C*/#define at24c02 0xa0 /*IC*/*/uchar ack; /*/*/uchar mun_to_char=0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e;/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */*/uchar code sled_bit_table=0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe;/*: void Start_I2c();: I2C,I2C.*/void Start_I2c()SDA=1; /*/_Nop();SCL=1;_Nop(); /*4.7us,*/_Nop();_Nop();_Nop();_Nop();SDA=0; /*/_Nop(); /* 4s*/_Nop();_Nop();_Nop();_Nop();SCL=0; /*I2C */_Nop();_Nop();/*: void Stop_I2c();: I2C,I2C.*/void Stop_I2c()SDA=0; /*/_Nop(); /*/SCL=1; /*4s*/_Nop();_Nop();_Nop();_Nop();_Nop();SDA=1; /*I2C*/_Nop();_Nop();_Nop();_Nop();/*: void SendByte(uchar c);: c,.(ack=0 )ack=1; ack=0*/void SendByte(uchar c)uchar BitCnt;for(BitCnt=0;BitCnt8;BitCnt+) /*8*/if(cBitCnt)&0x80)SDA=1; /*/else SDA=0;_Nop();SCL=1; /*/_Nop();_Nop(); /*4s*/_Nop();_Nop();_Nop();SCL=0;_Nop();_Nop();SDA=1; /*8*/_Nop();_Nop();SCL=1;_Nop();_Nop();_Nop();if(SDA=1)ack=0;else ack=1; /*/SCL=0;_Nop();_Nop();/*: uchar RcvByte();: ,()*/uchar RcvByte()uchar retc;uchar BitCnt;retc=0;SDA=1; /*/for(BitCnt=0;BitCnt8;BitCnt+)_Nop();SCL=0; /*/_Nop();_Nop(); /*4.7s*/_Nop();_Nop();_Nop();SCL=1; /*/_Nop();_Nop();retc=retc1;if(SDA=1)retc=retc+1; /*,retc */_Nop();_Nop();SCL=0;_Nop();_Nop();return(retc);/*: void Ack_I2c(bit a);:,()*/void Ack_I2c(bit a)if(a=0)SDA=0; /* */else SDA=1;_Nop();_Nop();_Nop();SCL=1;_Nop();_Nop(); /*4s*/_Nop();_Nop();_Nop();SCL=0; /*I2C*/_Nop();_Nop();/*: bit ISendStr(uchar sla,uchar suba,ucahr *s,uchar no);: ,slasubasno1 ,no8Byte*/bit ISendStr(uchar sla,uchar suba,uchar *s,uchar no)uchar i;if(no=0) return(1);Start_I2c(); /*/SendByte(sla); /*/if(ack=0)return(0);SendByte(suba); /*/if(ack=0)return(0);for(i=0;ino;i+)SendByte(*s); /*/if(ack=0)return(0);s+;Stop_I2c(); /*/return(1);/*: bit IRcvStr(uchar sla,uchar suba,ucahr *s,uchar no);: ,slasubasno1 ,no8Byte*/bit IRcvStr(uchar sla,uchar suba,uchar *s,uchar no)uchar i;Start_I2c(); /*/SendByte(sla); /*/if(ack=0)return(0);SendByte(suba); /*/if(ack=0)return(0);Start_I2c();SendByte(sla+1);if(ack=0)return(0);for(i=0;ino-1;i+)* s=RcvByte(); /*/Ack_I2c(0); /*/s+;* s=RcvByte();Ack_I2c(1); /*/Stop_I2c(); /*/return(1);/*1MS*/void delay_1ms(uchar x)uchar j;while(x-)for(j=0;j125;j+);/*/void main()uchar i;uchar j;uchar temp2; /*IIC*/uchar sled_disp_buff8=0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff; /*8*/IRcvStr(at24c02,0x60,temp,2); /*/if(temp0!=temp1) /*EEPROMEEPROM*/temp0 = 0;temp1 = temp0;ISendStr(at24c02,0x60,temp,2); /*EEPROM*/temp0+;temp1 = temp0;ISendStr(at24c02,0x60,temp,2); /*EEPROM*/*/sled_disp_buff0 = 0xce; /* */sled_disp_buff1 = mun_to_chartemp0/0x10;sled_disp_buff2 = mun_to_chartemp0%0x10;sled_disp_buff3 = 0xf1; /* */sled_disp_buff5 = mun_to_chartemp0/100;sled_disp_buff6 = mun_to_chartemp0%100/10;sled_disp_buff7 = mun_to_chartemp0
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 题记指导课件
- 机票销售合同
- 电解工培训知识课件
- 电视主播专业知识培训课件
- 电装岗位基础知识培训课件
- 2025标准自助分租租赁合同范本
- 2025年签订汽车租赁合同技巧
- 电脑知识培训费用课件
- 电脑知识培训南京课件
- 春六年级语文下册第课科学幻想之父品读感悟教学设计冀教版冀教版小学六年级下册语文教案(2025-2026学年)
- 2025年人性本恶辩论赛辩论稿
- 风机叶片吊装安全培训课件
- 中国联通商洛市2025秋招笔试性格测评专练及答案
- 2025年第一期反洗钱专题培训测试题及答案
- 2026中国十九冶集团有限公司校园招聘笔试备考试题及答案解析
- 设备设施安全风险评估报告
- 学校优秀教职工代表推荐表
- 费森尤斯卡比中国临床营养业务研究报告
- 全息易象针灸手针穴位系统54页PPT课件
- 初中英语一般过去时课件(PPT)
- 新人教版小学一年级数学上册单元试卷全册
评论
0/150
提交评论