Tool/software: TI-RTOS
Hello,
I am using tirtos_tivac_2_16_01_14 and TivaWare_C_Series-2.1.4.178 for project. I am using one of the flash segment for storing non-volatile data for my application and this data will be written from one of the task in my application. This flash read and write will be frequent in my application.
After some times flash write, the entire flash is getting corrupted and reading all the values as 0xFFFFFFFF.
i thought there may task switching between flash erase and flash write and that causing the flash data is getting corrupted. then i changed the priority of flash write task to higher and checked but still the problem exist. can any one suggest what is happening here and why its getting corrupted after few writes?
is FlashProgram() and FlashErase() preempted? if so how do we block from preemption in TI RTOS?
please find the code snippet.
/* Flash Write */
void flashWrite(BOOT_STRUCT *stFlashData) { int ret; Semaphore_pend(Sem_flash_Handle, BIOS_WAIT_FOREVER); ret = FlashErase((uint32_t ) FLASH_COMMON_MEMORY_ADDRESS); if(ret != NULL) { System_printf("FLash memory is not erased successfully\n"); } ret = FlashProgram((uint32_t *)stFlashData, FLASH_COMMON_MEMORY_ADDRESS, 1024); if(ret != NULL) { System_printf("FLash memory is not programmed successfully\n"); } Semaphore_post(Sem_flash_Handle); }
/* Flash Read */
BOOT_STRUCT flashRead(BOOT_STRUCT *stFlashData) { Semaphore_pend(Sem_flash_Handle, BIOS_WAIT_FOREVER); stFlashData = ((BOOT_STRUCT *)FLASH_COMMON_MEMORY_ADDRESS ); Semaphore_post(Sem_flash_Handle); return *stFlashData; }
Regards
Bala