2021-11-15 06:12 AM
Hi everybody,
I'm sorry for poor English.
I'm using STM32F407VET6 in my board and I set up watchdog timer. However sometimes microcontroller hangs . Here is the main loop of my code:
while(TRUE)
{
// ======================================
clearWatchDog();
// ======================================
if (bRunTimingTask)
{
runTimingTask();
bRunTimingTask = FALSE;
}
// ======================================
if (bRunFlashModeTask)
{
runFlashModeTask();
bRunFlashModeTask = FALSE;
}
// ======================================
if (bRunGuiTask)
{
runGuiTask();
bRunGuiTask = FALSE;
}
// ======================================
if (bReadAdc)
{
ReadADCData();
bReadAdc = FALSE;
}
// ======================================
if(bSystemLogic)
{
SystemLogic();
bSystemLogic = FALSE;
}
}
First question is: why the watchdog timer doesn't reset the uController?
The flag bRunTimingTask is set in Systick interrupt routine every 10ms and the other flags like bSystemLogic, bReadAdc, bRunGuiTask, .. are set inside the runTimingTask() function.
The second question is: Is it possible that the Systick Interrupt be disabled suddenly and unwanted because of noise or other reasons?
Thanks
2021-11-15 10:33 PM
Hi Tesla DeLorean, The NRST pin pulled high externally with 10K ohm resistor.
2021-11-16 02:02 AM
Hello again,
I have one more question: Is it possible that the STM32F407 booted form system memory(which is used for programming by embedded bootloader) spontaneously because of the noise?
The big problem is that this situation is only happens occasionally, not always.
Thanks
2021-11-16 05:04 AM
How is BOOT0 pin connected?
JW
2021-11-16 11:38 PM
BOOT0 is pulled down with a 10K ohm resistor.
After several days I didn't get any result. Board working normally in lab, in the factory, working for several hours and suddenly all the hangs.
I'm really confused.
2021-11-16 11:42 PM
Hang with moved code clear? How clock use your design HSI or HSE? When HSE maybe your crystal fails. Try use HSI.
2021-11-16 11:57 PM
I'm using HSI. I'm testing the board in the lab and it doesn't hang and I can't test the moved code, because it never hangs. However I tested the watchdog and it works.
These is one strange problem: the customer says all the outputs disabled and the system hangs. Why the outputs goes off? and why watchdog doesn't reset? I doubt maybe STM32 enters BOOT mode or something like that.
2021-11-17 12:09 AM
Your primary code is bad and watchdog isnt prepared ok. For better protect change BOOT0 R to 1k or 100R when not used.
And just send to customer moved code for test.
One more Q what doing flashmode?
2021-11-17 01:05 AM
Thank you MM..1,
Here is the code I used to setup watchdog timer:
//Disable interrupts
__disable_interrupt();
//Watchdog timer setup:
IWDG->KR = 0x5555;
IWDG->PR = 0x04; // /64
IWDG->RLR = 0xFFF; //reload value
//start watchdog
IWDG->KR = 0xCCCC;
//Enable interrupts
__enable_interrupt();
I replaced 10K with 1K resistor and programmed the moved code. I will send it to customer today.
Thanks for your attention.