# Watchdog timer. Reset device after irq\_handler

**URL:** <https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156>\
**Category:** Peripherals\
**Tags:** evb-bw16, rtl872xd\
**Created:** [August 14, 2023, 12:38pm UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156 "2023-08-14T12:38:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chano](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/chano/32/1489_2.png) [@Chano](https://forum.amebaiot.com/u/Chano)\
**Post date:** [August 14, 2023, 12:38pm UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156/1 "2023-08-14T12:38:55Z")

</div>

Hi, I have a watchdog timer working and I would like to do some stuff if the watchdog barks before reseting the BW16. If I don’t configure an irq handler the device resets perfectly, but if I set an irq handler, the handler executes, but the device doesn’t reset.

How can I force a device reset?? Is there any api call to reset the BW16?

Thx!!

---

<div class="post-metadata">

**Author:** ![ruanjanc](https://avatars.discourse-cdn.com/v4/letter/r/6de8d8/32.png) [@ruanjanc](https://forum.amebaiot.com/u/ruanjanc)\
**Post date:** [August 14, 2023, 1:08pm UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156/2 "2023-08-14T13:08:59Z")

</div>

One solution is you have to call sys\_reset inside watchdog irq.

```auto
void my_watchdog_irq_handler(uint32_t id) {
    sys_reset();
}

```

---

<div class="post-metadata">

**Author:** ![Chano](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/chano/32/1489_2.png) [@Chano](https://forum.amebaiot.com/u/Chano)\
**Post date:** [August 14, 2023, 3:04pm UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156/3 "2023-08-14T15:04:01Z")

</div>

Thx for your prompt answer. which include do I need for this function??

error: ‘sys\_reset’ was not declared in this scope  
sys\_reset();

I’ve found this workround (but your’s is nicer! 🙂 )

> void my\_watchdog\_irq\_handler(uint32\_t id) {
> 
> … do stuff …
> 
> ```
> wdt.StopWatchdog();
> wdt.InitWatchdogIRQ(NULL, 0);
> wdt.InitWatchdog(50);
> wdt.StartWatchdog(); // enable watchdog timer
> 
> ```

---

<div class="post-metadata">

**Author:** ![ruanjanc](https://avatars.discourse-cdn.com/v4/letter/r/6de8d8/32.png) [@ruanjanc](https://forum.amebaiot.com/u/ruanjanc)\
**Post date:** [August 15, 2023, 2:03am UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156/4 "2023-08-15T02:03:08Z")

</div>

@Chano  
Seem you are using Arduino platform right ?  
I’m not sure for Arduino platform, but for standard SDK platform we must include “sys\_api.h”.

---

<div class="post-metadata">

**Author:** ![Chano](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/chano/32/1489_2.png) [@Chano](https://forum.amebaiot.com/u/Chano)\
**Post date:** [August 16, 2023, 7:00am UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156/5 "2023-08-16T07:00:25Z")

</div>

Yes, I’m using Arduino platform, I’m porting an ESP32 code to RTL8720. I could have re-write it to the Official SDK but I didn’t find a reason for it. is there something relevant in the official SDK that I should consider??

And, thx, sys\_api.h works in the arduino Platform

Thx again!!!  
Regards

---

<div class="post-metadata">

**Author:** ![ruanjanc](https://avatars.discourse-cdn.com/v4/letter/r/6de8d8/32.png) [@ruanjanc](https://forum.amebaiot.com/u/ruanjanc)\
**Post date:** [August 18, 2023, 1:18am UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156/6 "2023-08-18T01:18:28Z")

</div>

@Chano  
I also don’t know what exactly difference between official standard SDK platform and Arduino platform.  
One thing that I know is for product development it is recommended to use standard SDK platform.  
if your project going well with Arduino platform no need to change it I think.

---

<div class="post-metadata">

**Author:** ![dakamaster](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/dakamaster/32/1744_2.png) [@dakamaster](https://forum.amebaiot.com/u/dakamaster)\
**Post date:** [August 21, 2023, 2:31am UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156/7 "2023-08-21T02:31:19Z")

</div>

@ruanjanc ,

To clarify your question above, Ameba Arduino platform was ported based on standard sdk.

Thank you.

---

<div class="post-metadata">

**Author:** ![ruanjanc](https://avatars.discourse-cdn.com/v4/letter/r/6de8d8/32.png) [@ruanjanc](https://forum.amebaiot.com/u/ruanjanc)\
**Post date:** [August 21, 2023, 2:36am UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156/8 "2023-08-21T02:36:34Z")

</div>

@dakamaster  
Thank you for your clarify. Is Ameba Arduino platform able to use for products development ?

Thanks.

---

<div class="post-metadata">

**Author:** ![dakamaster](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/dakamaster/32/1744_2.png) [@dakamaster](https://forum.amebaiot.com/u/dakamaster)\
**Post date:** [August 21, 2023, 3:04am UTC](https://forum.amebaiot.com/t/watchdog-timer-reset-device-after-irq-handler/2156/9 "2023-08-21T03:04:09Z")

</div>

Could you please specify what kind of product you would like to develop?

Alternatively, you may refer to [Ameba ARDUINO – Realtek IoT/Wi-Fi MCU Solutions](https://www.amebaiot.com/en/ameba-arduino-summary/) for more information about Ameba(D) Arduino SDK.

Thanks
