AT24C02的多字节数据读写

时间:2021-02-15 19:48:12

这一点东西,弄个我一个小时,果然我还是太菜了

 1 unsigned char MultiByte_write (unsigned char add , int dat )//首地址  数据 返还尾地址
 2 {
 3     while(dat!=0)
 4     {
 5         Write_AT24C02(add,dat);
 6         dat>>=8;
 7         Write_AT24C02(add,dat);
 8         add<<=1;
 9         Delay1ms();
10     }
11     return add;
12 }
13 
14 int MultiByte_read (unsigned char add , unsigned char add1)//首地址 尾地址
15 {
16     int temp;
17     unsigned char i=0;
18     while(add < add1)
19     {
20         temp=Read_AT24C02(add);
21         add<<=1;
22         i++;
23         temp = Read_AT24C02(add) << 8*i | temp ;
24     }
25     return temp;
26 }