Helper library for using WWDG_IRQhandler() with Arduino_STM32 on STM32F103Cx/Rx microcontrollers. This is option for original Arduino_STM32 library. I checked this with Arduino IDE 1.8.8 + Arduino_STM32-master.zip (2020/04/22 10:35 44,077KB).
- Install Arduino_STM32
- Clone "wwdg.h" to "C:\Program Files (x86)\Arduino188\hardware\Arduino_STM32\STM32F1\system\libmaple\include\libmaple". (*) Need administrator privilege.
- Clone "wwdg.c" to "C:\Program Files (x86)\Arduino188\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple". (*) Need administrator privilege.
- Clone "isrs.S" from "C:\Program Files (x86)\Arduino188\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple\stm32f1\performance" to desktop or suitable folder for edit.
- Comment out following 3 lines (and add comment).
// .weak __irq_wwdg // __irq_wwdg() defined in ~/Arduino_STM32/STM32F1/cores/maple/libmaple/wwdg.c
// .globl __irq_wwdg
// .set __irq_wwdg, __default_handler
- Write back "isrs.S" to original folder. And you had better to rename original file for backup before write back. (*) Need administrator privilege.
- Include
libmaple/wwdg.hto your sketch. - Code away!
#define LED_BUILTIN PC13
#define WWDG_NEW_COUNTER 127 // min 65(0x41) to max 127(0x7F)
#include "libmaple/wwdg.h"
//---------------
void WWDG_IRQHandler(void) {
wwdg_counter_reload(WWDG_NEW_COUNTER);
wwdg_ewi_flag_clear();
digitalWrite(LED_BUILTIN, digitalRead(LED_BUILTIN)^1); // Blink
}
//---------------
void setup() {
Serial.begin(9600);
while (!Serial) { delay(100); }
Serial.println("BluePill-WWDG-blink-demo");
pinMode(LED_BUILTIN,OUTPUT);
// WWDG setup
wwdg_attach_callback(WWDG_IRQHandler); // attach interrupt service function
wwdg_init(127, 127, 3); // wwdg window=127, counter=127, devider=2^3=8. this parameter setting means max 57.3mS period
nvic_irq_set_priority(NVIC_WWDG, 2); // set priority 2. (*)NVIC_WWDG is defined at "nvic.h"
nvic_irq_enable(NVIC_WWDG); // interrupt enable. (*)this function is defined as 'static inline' at "nvic.h"
wwdg_ewi_flag_clear(); // pre-clear WWDG EWI flag
wwdg_ewi_enable(); // set WWDG EWI interrupt enable flag
}
//---------------
void loop() {
}
Please refer attached "BluePill-WWDG-verbose-demo.ino" and try several #define comment out/in.
Thanks for the hard work & inspiration for all the people working on STM32duino and Arduino_STM32!