Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 00003 #define IWDG_START 0x0000CCCC 00004 #define IWDG_WRITE_ACCESS 0x00005555 00005 #define IWDG_PR_PR_0 7 00006 #define IWDG_RELOAD 512*60 00007 #define IWDG_REFRESH 0xAAAA 00008 DigitalOut myled(LED1); 00009 int main() 00010 { 00011 /* (1) Activate IWDG (not needed if done in option bytes) */ 00012 /* (2) Enable write access to IWDG registers */ 00013 /* (3) Set prescaler by 8 */ 00014 /* (4) Set reload value to have a rollover each 100ms */ 00015 /* (5) Check if flags are reset */ 00016 /* (6) Refresh counter */ 00017 RCC_OscInitTypeDef RCC_OscInitStruct; 00018 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI; 00019 RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_0; 00020 HAL_RCC_OscConfig(&RCC_OscInitStruct); 00021 00022 IWDG->KR=IWDG_START; 00023 wait(5); 00024 IWDG->KR=IWDG_WRITE_ACCESS; 00025 IWDG->PR=IWDG_PR_PR_0; 00026 IWDG->RLR=IWDG_RELOAD; 00027 while(IWDG->SR) { 00028 wait(0.1); 00029 } 00030 //SwitchFromPLLtoHSI(); 00031 //RCC->CFGR = ( 00032 //0x00008000 00033 myled = 1; 00034 wait(3); 00035 myled = 0; 00036 wait(10); 00037 IWDG->KR=IWDG_REFRESH;/* (6) */ 00038 //HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI); 00039 deepsleep(); 00040 while(1) { 00041 00042 } 00043 }
Generated on Fri Jul 29 2022 05:59:31 by
