目前个人测试过AT24C02-AT24C128,感觉还可以。
里面没有页写函数,有兴趣的朋友可以补充一下,该程序仅供参考,源程序如下:
#include "led.h" #include "delay.h" #include "sys.h" #include "usart.h" #include "key.h" #include "24cxx.h" #include "myiic.h" //要写入到24c128的字符串数组 const u8 TEXT_Buffer[]={"STM32 AT24c128"}; #define SIZE sizeof(TEXT_Buffer) #define ADDRESS 163 //读写地址 int main(void) { u32 fan,fan1=6553; u8 datatemp[SIZE]; NVIC_Configuration(); delay_init(); //延时函数初始化 uart_init(9600); //串口初始化为9600 LED_Init(); //初始化与LED连接的硬件接口 KEY_Init(); //按键初始化 AT24CXX_Init(); //IIC初始化 while(AT24CXX_Check())//检测不到24c128 { delay_ms(500); LED0=!LED0;//DS0闪烁 } while(1) { //每一个函数都已经测试过,适合AT24C02-AT24C128 //AT24CXX_WriteOneByte(2049,fan1); //AT24Cxx_WriteTwoByte(16383,fan1); //AT24CXX_Write(ADDRESS,(u8*)TEXT_Buffer,SIZE); //printf("Write:%s\r\n",TEXT_Buffer); //显示写入内容 AT24CXX_WriteLenByte(0,fan1,2); delay_ms(1000); //fan=AT24CXX_ReadOneByte(2049); //fan=AT24Cxx_ReadTwoByte(16383); //AT24CXX_Read(ADDRESS,datatemp,SIZE); //printf("Read:%s\r\n",datatemp);//显示读取内容 fan=AT24CXX_ReadLenByte(0,2); printf("Read:%d\r\n",fan); } }