Hello everybody.
It's now some days that i'm trying to chase a problem consisting of individual bits that go from 0 to 1 with no apparent reason when a data structure is read from the flash memory byte by byte.
The microcontroller is a Kinetis Mk10dx32 clocked at 20 mhz , the FlexNvm EEEprom is not activated for this project and the FLASH_LDD of PE is used to perform the flash operations.
The interested area is at the end of the program flash, at 0x7000 and the dimension is 0x400
Has somebody experienced cases where the reads from flash of an array of bytes works fine but sometimes some bits in Ram results unexpectedly set to 1?
The phenomenon is intermittent and not reproducible while debugging until now,
I have a couple of boards (out of ten) that show it frequently and at least one of them stops showing the problem if I cool down the chip.
The error is always a bit that goes from 0 to 1 and never the other way.
The bit that is read unexpectedly to 1 will be properly read as 0 many of the following times.
Initially I thought it was a write or erase problem and did investigate about the flash endurance and all the possible erase/write problems, double checking the code against documentation and examples.
But after noticing that the bit change happens also when the read operation is performed alone (few seconds after the board power up the Flash is read but not written) I become convinced that is related to the read from flash operation.
Thanks for your opinion or link to interesting reading about this subject.
Best Regards, Mauro
Solved! Go to Solution.
I too had this problem after flash operations. You might need to increase stack size especially if you are saving the sector before writing. I fixed mine by increasing the stack.
I too had this problem after flash operations. You might need to increase stack size especially if you are saving the sector before writing. I fixed mine by increasing the stack.
Hello, I too have this problem. It started recently. I am using ke02. I have been doing a lot of flash write/erase for some time, for event logging purposes. Now some of my variables get corrupted after some flash read/write operations. This happens especially if I do multiple flash operations consecutively.
Does anybody know the flash endurance just affects a particular sector only or if the controller is usable after one particular sector has exceeded the endurance limit? Does changing the sector solve the problem?
Hello Mauro,
Can you put an example explaining the process you do to make this happen? (Details of the steps that the code is doing, where are you reading from, where do you put the data that you have read and where (Flash?RAM? Specify the exact address) is this happening.
For sure you are not going to see any bit of the flash going from 0 to 1 unless you erase a whole block, so I assume this is happening in the RAM.
Please give as much details as possible.
Regards,
Santiago
Hello Santiago
Thanks for your answer,
I am reading 158 bytes from location 0x7000 (Flash memory beyond the end of the code) and putting the data in RAM at 0x1ffff39c.
The project is a CW10.6 with Processor Expert and use the Component FLASH_LDD .
The operating temperature is around 20 degree Celsius, the power supply is stable and the environment is "electrically quiet" , as the boards are placed in the basement of private houses
An Extract of the code follows. the code regarding the FLASH_EEPROM is taken from the example in the documentation of Component FLASH_LDD - CW 10.6
Please let me know which other details are needed to figure out better the problem and consider that I can see the problem on some of the boards but not able until now to replicate in debug mode
Regards, Mauro
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
... from main, every ten minutes those functions are called in order to store information that persist in case the power goes off
EEPromError = EEPromWrite();
EEPromError = EEPromRead();
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// interrupt
void FLASH_EEPROM_OnOperationComplete(LDD_TUserData *UserDataPtr)
{
EEPromDataWrittenFlg = TRUE;
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LDD_TError EEPromWrite()
{
EEPromDataWrittenFlg = FALSE;
EEPromError = FLASH_EEPROM_Write(MyFLASH_Ptr, (LDD_TData *)EEPromDataToStore.arrByte, MY_FLASH_LOCATION, sizeof(EEPromDataToStore)); /* Start writing to the flash memory */
if(EEPromError != ERR_OK)
return EEPromError;
while (!EEPromDataWrittenFlg) // the flag is set by the FLASH_EEPROM_OnOperationComplete interrupt
{
Bit_night_SetVal(NULL);
/* Wait until the data are written */
nTestAttesaWrite++;
Bit_night_ClrVal(NULL);
}
EEPromDataWrittenFlg = FALSE;
if (FLASH_EEPROM_GetOperationStatus(MyFLASH_Ptr) == LDD_FLASH_FAILED)
{ /* Check if the operation has successfully ended */
/* Error state solution */
return ERR_FAILED; /* Return ERR_FAILED */
}
Bit_night_ClrVal(NULL);
return ERR_OK; /* Return with no error */
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LDD_TError EEPromRead()
{
EEPromError = FLASH_EEPROM_Read(MyFLASH_Ptr, MY_FLASH_LOCATION, (LDD_TData *)EEPromDataRead.arrByte, sizeof(EEPromDataRead)); /* Start reading from the flash memory */
if(EEPromError != ERR_OK)
return EEPromError;
do
{
FLASH_EEPROM_Main(MyFLASH_Ptr);
EEPromOpStatus = FLASH_EEPROM_GetOperationStatus(MyFLASH_Ptr);
} while (!((EEPromOpStatus == LDD_FLASH_IDLE) | (EEPromOpStatus == LDD_FLASH_FAILED)));
if (EEPromOpStatus == LDD_FLASH_FAILED)
{ /* Check if the operation has successfully ended */
return ERR_FAILED; /* Return ERR_FAILED */
}
return ERR_OK; /* Return with no error */
}
Dear Mauro,
Now, I also have a problem similar to your case.
Did you already solve this problem?
Thanks,
George