Hi,
I'm testing internal EEPROM of LPC54606 in which I want to write 64 bytes using EEPROM_Write() function. But after calling this function controller goes in Hardfault handler and then not able to write data into EEPROM.
I have referred lpcxpresso54628_eeprom example project.
I'm attaching my test project for reference.
Hi,
I have checked your code, I suppose that byou have modified the SDK example code.
If you use the SDK example code without any modification, do you have any issue?
BR
XiangJun Rong
Hi,
for your code:
for (i = 0; i < 1; i++)
{
EEPROM_Write(EXAMPLE_EEPROM, u16Address, data, u16BytesToWrite);
for (j = 0; j < u16BytesToWrite / 4; j++)
{
eeprom_data = *((uint32_t *)(FSL_FEATURE_EEPROM_BASE_ADDRESS + i * u16BytesToWrite + j * 4));
if (eeprom_data != data[j])
{
err++;
PRINTF("Page %d offset %d is wrong, data is %x \r\n", i, (j * 4), eeprom_data);
}
}
PRINTF("Page %d program finished!\r\n", i);
u16Address += u16BytesToWrite;
}
The EEPROM page size is 0x4000/128=128 bytes, if you define u16BytesToWrite as 128, the EEPROM_Write() function will become page program.
Pls have a try
Generally, the wrong address will leads to hardfault error.
BR
XiangJun Rong
If you use the SDK example code without any modification, do you have any issue?
-> No I don't get any error if using EEPROM_WritePage() to write data into EEPROM.
But I don't want to write all 128 bytes (1 page) hence not using EEPROM_WritePage().
The EEPROM page size is 0x4000/128=128 bytes, if you define u16BytesToWrite as 128, the EEPROM_Write() function will become page program.
-> If I change u16BytesToWrite to 128 then also I'm getting hardfault error.
Is there any mistake in my test routine?
Can you run this code and will let me know if there is no hardfault error?
Hi,
Hi,
I have not LPC54628-EVK board on hand, pls try to test. If you still have issue, I will test on Tuesday next week.
Pls try to execute the line, and check which line leads to the hardfault
EEPROM_Write(EXAMPLE_EEPROM, u16Address, data, u16BytesToWrite);
for (j = 0; j < u16BytesToWrite / 4; j++)
{
eeprom_data = *((uint32_t *)(FSL_FEATURE_EEPROM_BASE_ADDRESS + i * u16BytesToWrite + j * 4));
if (eeprom_data != data[j])
{
err++;
PRINTF("Page %d offset %d is wrong, data is %x \r\n", i, (j * 4), eeprom_data);
}
BR
XiangJun Rong
Pls try to execute the line, and check which line leads to the hardfault
-> I don't get error while debugging (step in).
But in runtime MCU goes in hardfault handler.
Not able to understand this.
Hi,
I suppose that you can not write EEPROM in a forever loop.
BR
XiangJun Rong
I'm still not able to write data into EEPROM. I'm getting Hardfault error.
In Chapter 47: LPC546xx EEPROM memory (UM10912) AUTOPROG mode is mentioned.
I'm using AUTOPROG = 01: Writing a single word to the page starts the erase/program cycle
automatically. This mode is useful store small data items (word) on random locations.
But I'm not able to get steps to do the same.
Can you provide example code for this configuration (AUTOPROG = 01) using EEPROM_Write().
I have also attached my test project please guide me with this.