2023-05-23 01:00 AM - edited 2023-11-20 04:49 AM
I am using external flash (16Mb) for TouchGFX resources (normaly in memory mapped mode). I would also like to save some parameters to external flash in runtime while using the application.
Bellow is current code handeling writing to external flash (using EEPROM) library. eepromCtrl function is called in separate task every 25ms. inside I check the queue if there are some things to save to external flash. If there is something then I call
This works ~90% of the time but sometimes crashes. What can I do better?
void eepromCtrl(){
uint8_t EEpromQueueFillLevel = uxQueueMessagesWaiting(Queue_To_EEpromHandle);
if((EEpromQueueFillLevel <= 0) || !enableEEpromWriting){
return;
}
eepromWriteCount++;
baseType = xQueueReceive(Queue_To_EEpromHandle, &eepromQueueMsg, 1);
if ((baseType == pdPASS) && (eepromQueueMsg.id > 0)) {
taskENTER_CRITICAL();
NVIC_DisableIRQ(DMA2D_IRQn);
NVIC_DisableIRQ(LTDC_IRQn);
NVIC_DisableIRQ(TIM5_IRQn);
stat = ExtFlash_Abort(&hqspi);
if(stat == EXT_FLASH_OK){
ee_status = EE_WriteVariable32bits(eepromQueueMsg.id,eepromQueueMsg.value);
}
if (ee_status == EE_CLEANUP_REQUIRED) {
if (EE_CleanUp() != EE_OK) {
};
}
stat = ExtFlash_MemoryMap(&hqspi);
NVIC_EnableIRQ(TIM5_IRQn);
NVIC_EnableIRQ(DMA2D_IRQn);
NVIC_EnableIRQ(LTDC_IRQn);
taskEXIT_CRITICAL();
}
}