Try to wake up the halt() low power mode through the RTC interrupt. A low power clock source is needed as the RTC running clock. Select LSI's 16-division clock as the clock source:
void RCC_LSI(void)
{
CLK_LSICmd (ENABLE);
CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_LSI);
while(CLK_GetFlagStatus(CLK_FLAG_LSIRDY)==RESET);
CLK_SYSCLKSourceSwitchCmd (ENABLE);
if(CLK_GetSYSCLKSource()==CLK_SYSCLKSource_LSI)
{
CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_16);
}
}
RTC interrupt settings:
RTC_DeInit();
CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
CLK_RTCClockConfig(CLK_RTCCLKSource_LSI, CLK_RTCCLKDiv_64);
RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);
RTC_ITConfig(RTC_IT_WUT, ENABLE);
RTC_SetWakeUpCounter(time);
RTC_ClearITPendingBit(RTC_IT_WUT);
There is no direct enable here because during the debugging process, this part of the settings is under high-speed clock. If all of this part of the settings are placed after RCC_LSI(), it will get stuck, so only RTC_WakeUpCmd(ENABLE) is placed after the RCC_LSI() function.
After the halt() or wfi() mode is awakened by the RTC interrupt, it switches back to the high-speed internal clock:
void RCC_HSI(void)
{
CLK_HSICmd(ENABLE);
CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI);
while(CLK_GetFlagStatus(CLK_FLAG_HSIRDY)==RESET);
CLK_SYSCLKSourceSwitchCmd (ENABLE);
if(CLK_GetSYSCLKSource()==CLK_SYSCLKSource_HSI)
{
CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
}
}
When trying to switch directly from LSI to HSI and failing, an error occurs when STLINK connects to the MCU:
Failed to get execution status: SWIM error [30004]: Comm timeout. Because it occurs during debugging, there is no sudden hardware abnormality. This connection error can only be attributed to the MCU system clock not working. In this case, it is because the clock does not transition normally. It occurs when switching the clock from LSI to HSI during debugging. According to some clues obtained on the Internet, it may be related to the -"|" or - of the register operation.
When developing with IAR for STM8, if the project is large and the structure is complex, or the file name is changed frequently, the software may crash:
Fatal Error[Pe1696]: cannot open source file "stm8l15x_pwr.h". Due to the crash of IAR software, the originally normal project reported many such errors. I had to add the reference folder again.
There is another type of error:
Fatal error: Unknown exception in driver (SD1) Session aborted!
The answer that can be found on the Internet is that this is because IAR is not on the same system disk as Texas Instruments, but this is also sudden and should not be related to the problem of installation directory. After the project is completed, this problem strangely disappeared.
Previous article:Problems with using printf to print floating point numbers in a single chip microcomputer
Next article:STM8->GPIO
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- [NXP Rapid IoT Review] Hello Sensor
- What are the advantages of electronic load switches over MOS or transistors as output control? Now many domestic semiconductor...
- Lighter igniter electric shock/ignition principle
- This is the second time I haven't seen any replies in the past few days. The pattern is: there are replies on the 20th floor, but no more on the 21st floor; there are replies on the 40th floor, but no more on the 41st floor...
- Find TI, NXP, ALTERA, XILINX, ST, Microchip factory stock chips
- Record the use of TM1668 driver
- Newbie help, ESP8266 program problem
- GaN Applications in RF and Electronics
- CC2530 Basic Experiment 1 I/O Experiment Code
- Qorvo Online Design Conference - Wi-Fi Architecture and Future Development of Wi-Fi Standards