cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 hang and watchdog doesn't reset

mh2
Associate III

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

17 REPLIES 17

Hi Tesla DeLorean, The NRST pin pulled high externally with 10K ohm resistor.

mh2
Associate III

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

How is BOOT0 pin connected?

JW

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.

Hang with moved code clear? How clock use your design HSI or HSE? When HSE maybe your crystal fails. Try use HSI.

mh2
Associate III

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.

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?

mh2
Associate III

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.