最近在学习用ke02的eeprom,但是用例程给出的擦和写的函数操作的时候怎么也没反应。用keil调试发现eeprom中全是0xAA,而且擦除了还是这样,这到底是怎么回事。查了查手册地址也没错,是0x10000000-0x100000ff。
这是代码,就是把官方的flash例程稍微修改了一点:
int main (void)
{
char ch;
uint32_t i;
uint8_t u8DataBuff[256];
sysinit();
printf("\nRunning the Flash_demo project.\n");
FLASH_Init(BUS_CLK_HZ);
//EEPROM_EraseSector(0x10000000);
//EEPROM_Program1Byte(0x10000000, 0x00);
/* Erase 99th sector */
//FLASH_EraseSector(30*FLASH_SECTOR_SIZE);
LED0_Init();
LED2_Init();
for(i=0;i<256;i++)
{
u8DataBuff[i] = (uint8_t)i;
}
/* write data to erased sector */
//FLASH_Program( 30*FLASH_SECTOR_SIZE,&u8DataBuff[0],256 );
EEPROM_Program(0x10000000, &u8DataBuff[0],256);
for( i=0;i<256/16;i++ )
{
for(ch =0;ch<16;ch++)
{
printf("0x%x,",*((uint8_t *)(i*16+ch+100*FLASH_SECTOR_SIZE)));
}
printf("\n");
}
while(1)
{
ch = in_char();
out_char(ch);
}
}
|