2021-03-25 12:17 AM
my code is jumping into hardfault handler during/after flash write procedure.some problem with mutex or task handling,
can somebody explains how to hold the thread until the flash write is complete.
note: flash write functions are called inside the "below normal " priority thread.
Solved! Go to Solution.
2021-04-19 06:21 AM
hi, i have fixed this issue,
there is problem in flashing of 96 K in 5 millisecond task, and other tasks are halt and ended with trap.
I have implemented a semaphore concept to flash block by block and the task un-interruption is solved.
2021-03-25 12:52 AM
can we see your "flash function" ?
Are you erasing flash pages before writting them?
Also, there is a lock unlock flash logic you should pay attention to.
Maybe this helps
flashaddr=0x8015000
uint32_t *p0=&mydata;
for (uint32_t i = 0; i < (sizeof(mydata)/4); ++i) {
HAL_FLASH_Unlock();
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (flashaddr), (uint32_t)*(p0+i));
CLEAR_BIT (FLASH->CR, (FLASH_CR_PG));
HAL_FLASH_Lock();
flashaddr+=4;
}
2021-03-25 01:27 AM
_disable_irq();
do{
sl_ret = BPC_FLASH_Block_Erase_l(FLASH_BANK_SECTOR_6, FLASH_BANK_2, ERASE_SECTOR_PARAM);
}while(sl_ret!=B_TRUE);
osDelay(2000);
BPC_FLASH_FlashWrite_l(&infoBlock1,pccom_adr_flash, (U_INT8 *)pccom_adr_ram, laenge_long);
__enable_irq();
but i guess , since i copy 96 kb of data from RAM to flash during write leads to thread lock and then causes systick exception with hardfault handler
2021-03-25 02:27 AM
i dont have experience about your specific setup but isnt disable_irq() dissabling your RTOS scheduler?
and maybe breaking something else?
2021-03-25 03:35 PM
To add to what Javier already said... Why are you disabling interrupts at all? Why is there a delay function? Have you read the FLASH section in the reference manual and understand how it works?
2021-04-19 06:21 AM
hi, i have fixed this issue,
there is problem in flashing of 96 K in 5 millisecond task, and other tasks are halt and ended with trap.
I have implemented a semaphore concept to flash block by block and the task un-interruption is solved.