如题.比如写入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
有奖活动 | |
---|---|
【有奖活动——B站互动赢积分】活动开启啦! | |
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |