2022-06-15 07:40 AM
Hello,
Our application is to count fast external interrupt with denouncing in EXTI_callback().
only When this interrupt is ongoing and try to write flash ,then STM32WLE5CC hangs, and reboot using Independent watchdog.
Write to flash code:
void emulated_eeprom_write_buf(uint8_t * buf, uint16_t length){
if((length)>2047) return;
uint32_t base_addr=0;
base_addr=getHexAddressPage(DATA_PAGE);
memoryPageErase(DATA_PAGE);
HAL_FLASH_Unlock();
for (uint32_t i = 0; i < length; i += 8)
{
uint64_t data64 = u8touint64(buf+i);
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, i + base_addr, data64) != HAL_OK)
{
HAL_FLASH_Lock();
return ;
}
}
HAL_FLASH_Lock();
}
In HAL_GPIO_EXTI_Callback() there is 50ms debounce check.
If there is no interrupt, then this issue doesn't arise.
please help us to solve this issue.
Thank You
2022-06-17 08:11 AM
Hi @DBhut.1 ,
It seems that you invert the Lock and the Unlock functions for the FLASH.
Please try to lock before writing in memory and to unlock after to see if it solve your issue.
Regards
2022-06-18 12:30 AM
In many tutorials I have seen that Flash_unlock() is used for to unlock flash for writing and then after write finish lock the flash again, so no further write possible without unlock for safety.
Also I tried your suggestion, but each time I am getting Hardfault error. and mcu stucks there, and reset using IWDG.
Could you please share proper mechanism to write and read custom data in Flash page for STM32WLE5CC.
2022-06-20 03:01 AM
Hello,
Yes sorry I mixed up the control register lock and the process lock during flash program.
So your configuration is ok.
You can refer to the FLASH_FastProgram example under Projects\NUCLEO-WL55JC\Examples\FLASH\FLASH_FastProgram of the STM32Cube_FW_WL_V1.2.0.
Regards
2022-06-22 12:49 AM
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPTVERR);
This is the extra line which is not in my code based on FLASH_FastProgram Example , will this can create this issue?
Also There is 50ms Debouncing checking inside EXTI callback at 0th priority(all other NVIC interrupt priority set to 1), So, will this can create issue, if there is Writing to flash and Interrupt occurs and interrupt takes 50ms( For debounce check )?
Our project is to count high frequency(say 30-50hz) pulses and we can't afford to miss pulse and our configuration is stored in Flash page, and on writing if pulse miss or device hangs can cause big trouble to us.
Thank You
2022-06-22 06:48 AM
Hello,
I have observed that I I init GPIO Pin and Interrupt after some delay time(say 1 second) then this issue doesn't face.
But, I am unable to understand the reason behind it, could you please help me regarding this.
Thank You
2022-06-28 02:28 AM
Hello @Louis AUDOLY (ST Employee) Please help me in this case, your response are valuable to us.
2022-06-28 06:43 AM
Hi,
When you talk about the delay it's between the GPIO init and the interrupt init ?
To answer to your previous message, I don't think this function can cause the issue, it will just clear the flag so nothing special.
If you have the same priority to the EXTI callback and the NVIC interrupt do you still have this issue ?
Regards