已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年衡水健康科技职业学院单招职业适应性测试模拟测试卷附答案
- 2026年南昌应用技术师范学院单招职业技能考试模拟测试卷附答案
- 2026年重庆工贸职业技术学院单招(计算机)测试模拟题库附答案
- 2026年黔南民族幼儿师范高等专科学校单招(计算机)测试模拟题库附答案
- 2026年甘肃省天水市单招职业适应性测试模拟测试卷附答案
- 2026年淮南职业技术学院单招职业倾向性测试题库附答案
- 2025年长治职业技术学院单招职业倾向性测试题库附答案
- 2026年衡水职业技术学院单招(计算机)考试备考题库附答案
- 2025年通辽辅警招聘考试真题及答案1套
- 2025年阜新矿务局职工大学辅导员招聘备考题库附答案
- 四川省成都市部分中学2026届高三上学期期中考试语文试卷及答案
- 辽宁省名校联盟2025年高三12月份联合考试生物试卷(含答案详解)
- 2026年中考英语一轮复习:一词多义(按字母顺序编排共233个)
- 新人教八年级上英语课件Unit 7 When Tomorrow Comes Section B(1a-2c)课件
- 2025年超星尔雅学习通《生态环境监测与数据分析》考试备考题库及答案解析
- 盐城师范学院《古代汉语(1)》2024-2025学年第一学期期末试卷
- 2025广东佛山市禅城区卫生健康系统招聘事业单位工作人员(第一批)9人笔试考试参考试题及答案解析
- 6.1生物的生殖-2025-2026学年人教版八年级《生物》下册学情评估卷
- 2025北京西城区政务服务中心大厅综合窗口服务岗招聘笔试考试备考题库及答案解析
- 2025上海对外经贸大学武装部干事招聘1人备考题库带答案解析
- 春节前安全教育培训 课件
评论
0/150
提交评论