cancel
Showing results for 
Search instead for 
Did you mean: 

How to add IWDG (independent watchdog) to an existing TrueStudio project.

LCice.2
Associate II

Hello everyone,

I am currently extending a legacy software, for STM32 ;

it is for : "stm32f103cb", with Atollic TrueStudio 9.3

I want to add IWDG (independent watchdog) ; to do so I generated a new project using CubeIDE, latest version, driven by a proper youtube tutorial on IWDG and STM32.

Then I manually copied the needed code into my existing project.

My question is :

is it enough to copy only the C code, into the existing project, to get the IWDG properly working ?

Or there is additional setup to be done that cannot be copied this way ?

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

Copying the relevant init code from main.c and the library .c + .h files. Search for IWDG in the whole new project.

If both, the old and the new project use the same libs (HAL?), it should work. If not, let CubeIDE import (a copy of) the old project.

View solution in original post

5 REPLIES 5
KnarfB
Principal III

Copying the relevant init code from main.c and the library .c + .h files. Search for IWDG in the whole new project.

If both, the old and the new project use the same libs (HAL?), it should work. If not, let CubeIDE import (a copy of) the old project.

LCice.2
Associate II

Thank you, KnarfB, for the quick answer ; i will do this eway ;

not immediately, due to my target environment issues... ( I omit all the details... :).

One detail : my STM32 is embedded into a mainboard, and it is not easy to test the Software and detect if the watchdog really performs the reset or not.

We have to toggle some pins, and read the voltage on those pins . . . . it takes time...

(I do not have, on my desk, an evaluation board, but I am seriously thinking of buying it)

Anyway, I will let you know.

Thanks.

LCice.2
Associate II

Hello everyone, I made a first test, using only the pasted code ;

I avoided refreshing the watchdog, so to cause a reset, but the reset did not happen.

I was using the debugger : maybe this could be an issue ?

I knew that a working watchdog works ALSO during a debugging session, also when a breakpoint has been hit.

I will go on trying to generate a minimal SW that uses the Watchdog, and really performs the reset of my STM32.

Only then, I w8ill try to port this code into my ful original SW.

LCice.2
Associate II

Hello everyone,

Not only, thje watchdog does not reset the STM32 ;

but, in the whole project, as soon as i call the refresh function of the HAL ( HAL_IWDG_Refresh )

the result code is : HAL_TIMEOUT

Then, the software becomes unable to send and receive data over the serial port.

The remaining tasks of the SW seem to continue working correctly.

But the correct working of the serial port is gone.

It seems to me an incorrect setup , at the beginning.

Should I try first a simple standalone program to setup the watchdog ?

Thank you.

LCice.2
Associate II

Also standalone program does not work.

Do you want to hear about "WHY" watchdog seemed to be not working ?

Because there was a missing line of code ;

cubeMX does not write the following needed line of code :

HAL_IWDG_Start(&hiwdg) ;

Cube MX 4.27 does not write this line.

But also latest version, 6.1.1, does not.

I discovered this, by looking directly into the source code of the HAL library.

is this . . . normal ???

Now the independent watchdog is smoothly working.