一、1字节8为的读写
u8 a=10;u8 temp;
eeprom_write(0x00,a);
temp=eeprom_read(0x00);
sprintf(text," temp=%d ",temp);
LCD_DisplayStringLine(Line1,(u8*)text);
memset(text,'\0',strlen(text));
二、对于uint16_t、int16_t、等2个字节的数据类型,需要进行位运算,屏蔽低8位或高8位。依次写入高8位和低8位。
1. 2字节16位数据的写入
uint16_t temp;
uint16_t a=1200;u8 data;
data =a>>8; //先写入高8位
eeprom_write(0x00,data);HAL_Delay(5);
data =a&0x00ff; //再取出低八位
eeprom_write(0x01,data);
2. 2字节16位数据的读并显示
u8 data;
data= eeprom_read(0x00);
temp=data;
temp<<=8; //将高8位移动
data=eeprom_read(0x01);
temp |=data; //拼接成16位sprintf(text," a=%d ",a);
LCD_DisplayStringLine(Line2,(u8*)text);
memset(text,'\0',strlen(text));
标签:u8,temp,text,0x00,嵌入式,蓝桥,AT24C02,data,eeprom From: https://blog.csdn.net/qq_50284870/article/details/137117665