I am having difficulties getting multiple words to be written to the EEPROM using the EEPROMProgram method. Are you aware of any problems with this method?
I’ve been testing with 4 words. The first three words always seems to be written correctly to EEPROM. However, the fourth word is never written as expected.
Microcontroller: TM4C1290NCPDT
Code Details
Test method()
{
…
// Testing for multiple word WriteData method
uint32_t read1[4] = {0, 0, 0, 0};
IEeprom_API.ReadData(1600, read1, 16);
// Uncomment one of the following arrays to write during a particular test run
uint32_t write[] = {0x12345678, 0x23456789, 0x34567890, 0x45678901};
// uint32_t write[] = {0x00345678, 0x00456789, 0x00567890, 0x00678901};
// uint32_t write[] = {0x123456FF, 0x234567FF, 0x345678FF, 0x456789FF};
uint32_t writeStatus = IEeprom_API.WriteData(1600, write, 16);
uint32_t read2[6] = {0, 0, 0, 0};
IEeprom_API.ReadData(1600, read2, 16);
// breakpoint set on line of code here to see what values are in read1, write, and read2 arrays
…
}
// My WriteData method which calls the EEPROMProgram method
WriteData(uint32_t StartAddress, uint32_t * pData, uint32_t DataSize) method
{
…
if( GetBlockProtection() != eNoProtection)
{
SetBlockProtection(eNoProtection);
}
// This is the method call I expected to work
ProgramStatus = MAP_EEPROMProgram( pData, StartAddress, DataSize);
// I tried this method call which still did not work
// ProgramStatus = EEPROMProgram( pData, StartAddress, DataSize);
// The following code segment works fine. Here we are programming a single word at a time.
// When this code segment is used all four bytes are written every time the test has been run.
// uint32_t address = StartAddress;
// uint8_t numLoops = DataSize/4;
// for( int i = 0; i < numLoops; i++ )
// {
// ProgramStatus = MAP_EEPROMProgram( pData+i, address, sizeof(uint32_t));
// address += 4;
// }
SetBlockProtection(eFullProtection);
…
}
Here are the results of a GOOD run of the code, writing a single word at a time with the [MAP_]EEPROMProgram method
read1[ ] = 0x12345678, 0x23456789, 0x34567890, 0x45678901 // Initial values in EEPROM write[ ] = 0x123456FF, 0x234567FF, 0x345678FF, 0x456789FF // Values written to EEPROM read2[ ] = 0x123456FF, 0x234567FF, 0x345678FF, 0x456789FF // Final values read from EEPROM
The results are that the 4 words were correctly written to the EEPROM (i.e. read2 == write)
Here are the results of a FAILED run of the code when trying to writing multiple words from the [MAP_]EEPROMProgram method
read1[ ] = 0x12345678, 0x23456789, 0x34567890, 0x45678901 // Initial values in EEPROM write[ ] = 0x123456FF, 0x234567FF, 0x345678FF, 0x456789FF // Values written to EEPROM read2[ ] = 0x123456FF, 0x234567FF, 0x345678FF, 0x45678901 // Final values read from EEPROM
The results are that the first three words were correctly written to the EEPROM but the fourth word was not (i.e. read2[3] != write[3])
I have stopped in the debugger before the call to the [MAP_]EEPROMProgram method and verified the expected variables being passed into it.
Please let me know if you are aware of any problems in this regard and provide any suggestions for fixing this issue.