求助:使用EEPROM记录数据出错,请高手指点,谢谢!
- UID
- 518620
- 性别
- 男
|
求助:使用EEPROM记录数据出错,请高手指点,谢谢!
下面是我使用的EEPROM的程序,想记录一些数据,但是每次都不对,单片机运行正常,不知道是哪儿出了问题,请大虾们指点迷津,谢谢! #define eclkdiv (*((volatile unsigned char*)(0x0110))) #define ecnfg (*((volatile unsigned char*)(0x0113))) #define eprot (*((volatile unsigned char*)(0x0114))) #define estat (*((volatile unsigned char*)(0x0115))) #define ecmd (*((volatile unsigned char*)(0x0116))) unsigned char relative_addr; #define EE_BASE ((volatile unsigned int*)(0x2000)) volatile unsigned int * ee_addr = EE_BASE; void wreeprom(void) { //put your own code here ECLKDIV = 0x4b; while(!(ECLKDIV&0x80)); while(!(ESTAT&0x80)); while(!(EPROT&0x80));
for(relative_addr=0;relative_addr<14;relative_addr++) { *ee_addr = (int)(unit[relative_addr]*100); ee_addr=ee_addr+1; ECMD = 0x20; ESTAT |= 0x80; while(!(ESTAT&0x40)); } *ee_addr = time2; ee_addr=ee_addr+1; ECMD = 0x20; ESTAT |= 0x80; while(!(ESTAT&0x40)); *ee_addr = PACN10; ee_addr=ee_addr+1; ECMD = 0x20; ESTAT |= 0x80; while(!(ESTAT&0x40)); }
|
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
|
|
|
|
|