Using the WWDG of STM32F030, it is found that the MCU will not be reset under STOP, just like the sleep mode of STM8S.
Paste the watchdog code:
/****************************************************** ***************************************
*************************************************** ***************************************
* FILE : wdog_drv.c
* Description:
*
* Copyright (c) 2015 by LAN. All Rights Reserved.
*
* History:
* Version Name Date Description
0.1 Blue Dawn 2015/01/28 Initial Version
*************************************************** ***************************************
*************************************************** ***************************************/
#include "wdog_drv.h"
#define WWDG_Prescaler_8 ((uint32_t)0x00000180)
#define CFR_WDGTB_MASK ((uint32_t)0xFFFFFE7F)
#define RCC_APB1ENR_WWDGEN ((uint32_t)0x00000800) /*!< Window Watchdog clock enable */
/*================================================ ==================
* Function: Wdog_Init
* Description: Watchdog initialization
* Input Para :
* Output Para :
* Return Value:
================================================== ================*/
void Wdog_Init(void)
{
Wdog_Start();
WWDG->CFR |= 0x7F; //The upper window of the window watchdog, the window value must be above 0x3F, but must be less than the count value less than 0x7F
WWDG->CR = 0x7F; //Watchdog count value
Wdog_Feed(0);
}
/*================================================ ==================
* Function: Wdog_Start
* Description: Start the door dog
* Input Para :
* Output Para :
* Return Value:
================================================== ================*/
void Wdog_Start(void)
{
RCC->APB1ENR |= RCC_APB1ENR_WWDGEN;
//Set the divided clock
WWDG->CFR = (WWDG->CFR & CFR_WDGTB_MASK) | WWDG_Prescaler_8;
WWDG->CR |= 0x80; // Enable window watchdog
}
/*================================================ ==================
* Function: Wdog_SetReload
* Description : Reset frequency
* Input Para :
* Output Para :
* Return Value:
================================================== ================*/
void Wdog_SetReload(u8 uTime)
{
}
/*================================================ ==================
* Function : Wdog_Feed
* Description : Feed the dog
* Input Para :
* Output Para :
* Return Value:
================================================== ================*/
void Wdog_Feed(u8 uTime)
{
if ((WWDG->CR & 0x7F) < WWDG->CFR) //The dog can be fed only if it is less than the window value
{
WWDG->CR |= 0x7F; //Re-feed the dog
}
}
/*================================================ ==================
* Function: Wdog_ResetChip
* Description: Reset chip
* Input Para :
* Output Para :
* Return Value:
================================================== ================*/
void Wdog_ResetChip(void)
{
while ((WWDG->CR & 0x7F) >= WWDG->CFR)
{//Wait to enter the dog feeding window
}
WWDG->CR &= 0x40; //Minimum reset
while(1);
}
Previous article:keil For ARM function absolute definition
Next article:STM32 hardware CRC32 usage
Recommended ReadingLatest update time:2024-11-16 13:02
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications