使用STM8S207CBT6
定义EEPROM,如下:
//红色
#pragma location=0x4000
__root const char EePwmR0 = 0;
#pragma location=0x4001
__root const char EePwmG0 = 1;
#pragma location=0x4002
__root const char EePwmB0 = 2;
#pragma location=0x4003
__root const char EePwmStep0 = 3;//过渡时间=20*400us*256=2.048s
#pragma location=0x4004
__root const char EePwmKeep0H = 4;//保持时间10s
#pragma location=0x4005
__root const char EePwmKeep0L = 5;//保持时间10s
程序中,读取EEPROM的代码如下:
PwmNewR = *(unsigned long*)0x4000;
PwmNewG = *(unsigned long*)0x4001;
PwmNewB = *(unsigned long*)0x4002;
PwmStep = *(unsigned long*)0x4003;
PwmKeep = *(unsigned long*)0x4004;
PwmKeep<<=8;
PwmKeep |= *(unsigned long*)0x004005;
仿真时,得到的数据,偏偏无法读取前面3个字节,本来是从0x4000开始读取,结果是从0x4003开始读取的
不知道撞什么鬼,
按说从0x4000开始读取,得到的结果应该是:0x00,0x01,0x02...
而实际仿真的结果是0x03,0x04,0x05...
仿真时可以看到EEPROM定义的数据没错,就是读不出来,
不会贴图 |