为什么使用官方的把approm作eeprom使用,读出来的时钟是0x00,初始化状态下不应该是0xff吗?
#define DATA_MAX_SIZE 4096
#define DATA_START_ADDR 0x3800
#define FLASH_SUCESS 0x00
#define FLASH_FAIL 0x01
#define FLASH_FULL 0x02
#define FLASH_NOVAID 0X03
uint8 Api_Read_Data_From_Flash(uint8 *buf,uint16 addr,uint8 len)
{
uint8 i;
if(addr<DATA_START_ADDR)return FLASH_NOVAID;
set_IAPEN;
IAPAL = LOBYTE(addr);
IAPAH = HIBYTE(addr);
IAPCN = BYTE_READ_AP;
for(i=0;i<len;i++)
{
if(addr>DATA_START_ADDR+DATA_MAX_SIZE)
{
clr_IAPEN;
return FLASH_FULL;
}
set_IAPGO;
if((CHPCON&SET_BIT6)==SET_BIT6)
{
clr_IAPFF;
return FLASH_FAIL;
}
*buf=IAPFD;
buf++;
addr++;
IAPAL = LOBYTE(addr);
IAPAH = HIBYTE(addr);
}
clr_IAPEN;
return FLASH_SUCESS;
} |