如题.比如写入8个不同的参数。参数是16位的。假定写入11111,22222,33333,44444,55555,6666,7777,8888.
那么,如何在24C16里面将其分配到不同的存储空间存取。如何划分写入区域,如何指定地址?
假如我的写函数定义为:void AT24CXX_WriteByte(uint16_t ByteAddr,uint8_t ByteVal)
现在要写入uint16_t Write_Word = 0x1234,写到地址uint16_t Word_Addr=0x12;
则代码如下:
#ifdef __BIG_END //if the system is big-end mode
AT24CXX_WriteByte(Word_Addr,(Write_Word&0xFF00)>>8);//write the higt Byte
AT24CXX_WriteByte(Word_Addr+1,Write_Word&0xFF);//write the low Byte
#else //if the system is little-end mode
AT24CXX_WriteByte(Word_Addr,(Write_Word&0xFF);//write the low Byte
AT24CXX_WriteByte(Word_Addr+1,(Write_Word&0xFF00)>>8);//write the high Byte
#endif