Implementing Watchdog on stm32f030

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Implementing Watchdog on stm32f030

Post by Alkaline »

Hello

I would like to implement an independent watchdog within my program.

I tried to follow some examples on the internet but I couldn't get it to work (probably due to my inexperience)

Is it possible to post an example of how to configure it?

Kind regards

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: Implementing Watchdog on stm32f030

Post by LeighM »

Here is an example based on the datasheet.
I've not tested it though.
Drop this code into a C icon to initialise the watchdog.
Then repeat step 6, the last line of code, at regular intervals to avoid reset.

Code: Select all

// 1. Enable the IWDG by writing 0x0000 CCCC in the IWDG_KR register.
IWDG->KR = 0xCCCC;
// 2. Enable register access by writing 0x0000 5555 in the IWDG_KR register.
IWDG->KR = 0x5555;
// 3. Write the IWDG prescaler by programming IWDG_PR from 0 to 7.
IWDG->PR = 7;
// 4. Write the reload register (IWDG_RLR).
IWDG->RLR = 0xFFF;
// 5. Wait for the registers to be updated (IWDG_SR = 0x0000 0000).
while (IWDG->SR);
// 6. Refresh the counter value with IWDG_RLR (IWDG_KR = 0x0000 AAAA)
IWDG->KR = 0xAAAA;

Alkaline
Posts: 143
Joined: Mon Aug 20, 2018 11:04 am
Has thanked: 42 times
Been thanked: 41 times
Contact:

Re: Implementing Watchdog on stm32f030

Post by Alkaline »

Hi LeighM

Thank you for the example

As soon as I try it I'll let you know!

Regards

Post Reply