Content originally posted in LPCWare by boscfab on Mon Mar 02 02:51:20 MST 2015
Hi,
sometime, after the power-up sequence, the first reading operation in to internal EEPROM fails.
The write procedure it's ok.
I use LPC4357 clocked at 204MHz and the EEPROM setup is this:
unsigned char Init_IIB(uint32_t eepromHz)
{
unsigned char strread[4];
LPC_EEPROM->PWRDWN = 0x0;
/* EEPROM is automate turn on after reset */
/* Setting clock:
* EEPROM required a 1500kHz. This clock is generated by dividing the
* system bus clock.
*/
//eepromHz/=2;
Delay(10); //10ms
LPC_EEPROM->CLKDIV = eepromHz / (EEPROM_CLOCK_DIV-1); // 31 ; //EEPROM clock=1500 KHz
LPC_EEPROM->RWSTATE = (eepromHz / 28571429 + 1) | ((eepromHz / 14285714 + 1) << 8); //(0x3 | 0x5<<8); // Read waitstates.
LPC_EEPROM->WSTATE = ((eepromHz / 50000000 + 1) << 16) | ((eepromHz / 25000000 + 1) << 8) | (eepromHz / 100000000 + 1); // (0x2 | 0x3<<8 | 0x2<<16); //EEPROM wait state register
LPC_EEPROM->AUTOPROG = EEPROM_AUTOPROG_AFT_1WORDWRITTEN;//01 = erase/program cycle is triggered after 1 word is written
Delay(10); //10ms
{
volatile unsigned char *pchar;
pchar = (uint8_t*)(EEPROM_START + (126*32*4)-0x100);
if(pchar[0]==0xAA && pchar[1]==0x55 && pchar[2]==0xAA && pchar[3]==0x55) \\Check signature EEPROM
return TRUE;
}
return FALSE;
For testing this problem i check the signature at power up (0xAA, 0X55, 0xAA, 0x55).
Sometime during after the power up the signature check return all 0xFF.....strange!
If i make a loop for the signature check, after some cycle, the result it's ok.
Do you have suggestions?
I added the wait state in RPHASE read and write but nothing changes.
Thanks,
Fabio