本帖最后由 damiaa 于 2017-11-30 14:49 编辑 STM32F0的标准库的 uint32_t sEE_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite) uint32_t sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead) 函数貌似有个BUG 其实也不一定说是BUG,至少是不方便,迷惑使用着吧,因为调用者不会老盯住sEEAddress去切换扇区啊。 就是写24LC16时地址0X100以前的数据可以读写 0X100以上的数据又把0X100以内的空间覆盖了 有人遇到过吗? 怎么解决的? 已经解决: 一,调用该函数之前改变sEEAddress //#define sEE_HW_ADDRESS 0xA0 /* E2 = 0 */ // /*#define sEE_HW_ADDRESS 0xA2*/ /* E2 = 0 */ // /*#define sEE_HW_ADDRESS 0xA4*/ /* E2 = 0 */ // /*#define sEE_HW_ADDRESS 0xA6*/ /* E2 = 0 */ // /*#define sEE_HW_ADDRESS 0xA8*/ /* E2 = 0 *// // /*#define sEE_HW_ADDRESS 0xAA*/ /* E2 = 0 *// // /*#define sEE_HW_ADDRESS 0xAC*/ /* E2 = 0 */// /*#define sEE_HW_ADDRESS 0xAE*/ /* E2 = 0 */ /* Get number of reload cycles */ 二,函数内部改变sEEAddress uint32_t sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t* NumByteToRead) { uint32_t NumbOfSingle = 0, Count = 0, DataNum = 0, StartCom = 0; //还是这么改好: sEEAddress =0x00a0; sEEAddress +=(ReadAddr>>7)&0x000e;///////////////////20160811 ... } uint32_t sEE_WritePage(uint8_t* pBuffer, uint16_t WriteAddr, uint8_t* NumByteToWrite) { uint32_t DataNum = 0; sEE_WRITEALLOW(); //sEEAddress要改变 ,或者在调用该函数之前改变 //还是这么改好: sEEAddress =0x00a0; sEEAddress +=(WriteAddr>>7)&0x000e;///////////////////20160811 // num=4; // test2[0] =0x10; // test2[1] =0x20; // test2[2] =0x30; // test2[3] =0x40; // test2[4] =0x50; // test2[5] =0x60; // sEE_WriteBuffer(test2, 0x0, 4); // test2[0] =0x11; // test2[1] =0x22; // test2[2] =0x33; // test2[3] =0x44; // test2[4] =0x55; // test2[5] =0x66; // sEE_WriteBuffer(test2, 0x100, 4); //// sEE_ReadBuffer(&test[0], 0x100,&num); //// //// sEE_ReadBuffer(&test[0], 0x0,&num); |
【STM32F0开发日志/评测/笔记】+互补PWM波的产生
STM32F030 PB14和PB15无法输出PWM求助
【STM32F030探索套件】序列之五 外部中断
【STM32F0开发日志---二】+ucosii.2.92移植在STM32F030
上传个STM32F0+5110+内部温度传感器的菜鸟实例
【STM32F030探索套件使用问题】STM32F030 SPI方式驱动ST7565LCD失败
求一份STM32F051 I2C驱动LCD 12864的例程
STM32F0 M0 向结构体赋值进入HardFault异常
STM32F0 ADC-DMA方式采集2路数据时出现问题
STM32F030C8T6,TIM16定时慢很多问题?
应该就是这么回事
0x100就是十进制的256,显然超过了一个uint8_t的范围,对于uint8_t* NumByteToWrite来说。
uint16_t WriteAddr 这个是地址。 uint8_t* NumByteToWrite 是写字节数