Skip to content

SyojirouHaraguchiJapan/Arduino_STM32-WWDG-support

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STM32duino / Arduino_STM32 WWDG support

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).

Usage

  1. Install Arduino_STM32
  2. Clone "wwdg.h" to "C:\Program Files (x86)\Arduino188\hardware\Arduino_STM32\STM32F1\system\libmaple\include\libmaple". (*) Need administrator privilege.
  3. Clone "wwdg.c" to "C:\Program Files (x86)\Arduino188\hardware\Arduino_STM32\STM32F1\cores\maple\libmaple". (*) Need administrator privilege.
  4. 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.
  5. 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
  1. Write back "isrs.S" to original folder. And you had better to rename original file for backup before write back. (*) Need administrator privilege.
  2. Include libmaple/wwdg.h to your sketch.
  3. Code away!

Example

LED blink demo

   #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() {
   }

Verbose demo

Please refer attached "BluePill-WWDG-verbose-demo.ino" and try several #define comment out/in.

Misc

Thanks for the hard work & inspiration for all the people working on STM32duino and Arduino_STM32!

About

A library for adding WWDG support to Arduino_STM32

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors