MCU:PIC24H228
EEPROM:24LC32A 32bytes/page
我将页地址起始设置为0、32、64、128时,读写正常,其它(32倍数)的时不正常
#if 1
unsigned char ee_test[100];
for(i=0;i<100;i++)
ee_test[i]=i+10;
EEPROMPageWrite(0,ee_test,PAGE_SIZE);
Delayms(50);
EEPROMPageWrite(0+32,ee_test+32,PAGE_SIZE);
Delayms(50);
EEPROMPageWrite(0+64,ee_test+64,PAGE_SIZE);
Delayms(50);
EEPROMPageWrite(0+96,ee_test+96,4);
Delayms(50);
for(i=0;i<100;i++)
ee_test[i]=0;
EEPROMRead(0,ee_test,PAGE_SIZE);
for(i=0;i<PAGE_SIZE;i++)
{
sprintf(debug_str,"read:%d=%d\r\n",i,ee_test[i]);
DEBUG_PRINTSTR(debug_str);
}
EEPROMRead(0+32,ee_test,PAGE_SIZE);
for(i=0;i<PAGE_SIZE;i++)
{
sprintf(debug_str,"read32:%d=%d\r\n",i+32,ee_test[i]);
DEBUG_PRINTSTR(debug_str);
}
EEPROMRead(0+64,ee_test,PAGE_SIZE);
for(i=0;i<PAGE_SIZE;i++)
{
sprintf(debug_str,"read64:%d=%d\r\n",i+64,ee_test[i]);
DEBUG_PRINTSTR(debug_str);
}
结果:
read:0=10
read:1=11
read:2=12
read:3=13
read:4=14
read:5=15
read:6=16
read:7=17
read:8=18
read:9=19
read:10=20
read:11=21
read:12=22
read:13=23
read:14=24
read:15=25
read:16=26
read:17=27
read:18=28
read:19=29
read:20=30
read:21=31
read:22=32
read:23=33
read:24=34
read:25=35
read:26=36
read:27=37
read:28=38
read:29=39
read:30=40
read:31=41
read32:32=42
read32:33=43
read32:34=44
read32:35=45
read32:36=46
read32:37=47
read32:38=48
read32:39=49
read32:40=50
read32:41=51
read32:42=52
read32:43=53
read32:44=54
read32:45=55
read32:46=56
read32:47=57
read32:48=58
read32:49=59
read32:50=60
read32:51=61
read32:52=62
read32:53=63
read32:54=64
read32:55=65
read32:56=66
read32:57=67
read32:58=68
read32:59=69
read32:60=70
read32:61=71
read32:62=72
read32:63=73
read64:64=74
read64:65=75
read64:66=76
read64:67=77
read64:68=78
read64:69=79
read64:70=80
read64:71=81
read64:72=82
read64:73=83
read64:74=84
read64:75=85
read64:76=86
read64:77=87
read64:78=88
read64:79=89
read64:80=90
read64:81=91
read64:82=92
read64:83=93
read64:84=94
read64:85=95
read64:86=96
read64:87=97
read64:88=98
read64:89=99
read64:90=100
read64:91=101
read64:92=102
read64:93=103
read64:94=104
read64:95=105
该成这样之后,就不正常了
#if 1
unsigned char ee_test[100];
for(i=0;i<100;i++)
ee_test[i]=i+10;
EEPROMPageWrite(256,ee_test,PAGE_SIZE);
Delayms(50);
EEPROMPageWrite(256+32,ee_test+32,PAGE_SIZE);
Delayms(50);
EEPROMPageWrite(256+64,ee_test+64,PAGE_SIZE);
Delayms(50);
EEPROMPageWrite(256+96,ee_test+96,4);
Delayms(50);
for(i=0;i<100;i++)
ee_test[i]=0;
EEPROMRead(256,ee_test,PAGE_SIZE);
for(i=0;i<PAGE_SIZE;i++)
{
sprintf(debug_str,"read:%d=%d\r\n",i,ee_test[i]);
DEBUG_PRINTSTR(debug_str);
}
EEPROMRead(256+32,ee_test,PAGE_SIZE);
for(i=0;i<PAGE_SIZE;i++)
{
sprintf(debug_str,"read32:%d=%d\r\n",i+32,ee_test[i]);
DEBUG_PRINTSTR(debug_str);
}
EEPROMRead(256+64,ee_test,PAGE_SIZE);
for(i=0;i<PAGE_SIZE;i++)
{
sprintf(debug_str,"read64:%d=%d\r\n",i+64,ee_test[i]);
DEBUG_PRINTSTR(debug_str);
}
// sprintf(debug_str,"ee read:%d,%d",ee_test[PAGE_SIZE-2],ee_test[PAGE_SIZE-1]);
// DEBUG_PRINTSTR(debug_str);
#endif
结果:
read:0=10
read:1=11
read:2=12
read:3=13
read:4=14
read:5=15
read:6=16
read:7=17
read:8=18
read:9=19
read:10=20
read:11=21
read:12=22
read:13=23
read:14=24
read:15=25
read:16=26
read:17=27
read:18=28
read:19=29
read:20=30
read:21=31
read:22=32
read:23=33
read:24=34
read:25=35
read:26=36
read:27=37
read:28=38
read:29=39
read:30=40
read:31=73
read32:32=42
read32:33=43
read32:34=44
read32:35=45
read32:36=46
read32:37=47
read32:38=48
read32:39=49
read32:40=50
read32:41=51
read32:42=52
read32:43=53
read32:44=54
read32:45=55
read32:46=56
read32:47=57
read32:48=58
read32:49=59
read32:50=60
read32:51=61
read32:52=62
read32:53=63
read32:54=64
read32:55=65
read32:56=66
read32:57=67
read32:58=68
read32:59=69
read32:60=70
read32:61=71
read32:62=72
read32:63=105
read64:64=74
read64:65=75
read64:66=76
read64:67=77
read64:68=78
read64:69=79
read64:70=80
read64:71=81
read64:72=82
read64:73=83
read64:74=84
read64:75=85
read64:76=86
read64:77=87
read64:78=88
read64:79=89
read64:80=90
read64:81=91
read64:82=92
read64:83=93
read64:84=94
read64:85=95
read64:86=96
read64:87=97
read64:88=98
read64:89=99
read64:90=100
read64:91=101
read64:92=102
read64:93=103
read64:94=104
read64:95=255
希望大家帮忙看看,谢谢! |
|