In the official routine, PE6 is used as IDD_WAKUP to wake up the system from low power consumption.
STM8L has 5 low power consumption modes. The way to reduce power consumption can also be to reduce the system clock or turn off unused peripherals.
Today we will use U3, a 14-stage pulsating carry counter M74HC4060, to wake up the HALT mode. From the schematic diagram, we can see that the reverse connection of the output of Q14 pin is connected to the T2 analog switch to control the PE6 port. Because it passes through two inverters, the logic of Q14 is equal to the logic of PE6. The clock frequency of U3 is 30KHZ, and the pulse period of Q14 is 2 to the 14th power divided by 30KHZ, which is approximately equal to 0.5s, that is, the pulse output by Q14 is a square wave with a period of about 1 second and a duty cycle of 1:1. Therefore, the level change of PE6 is also a square wave with a period of about 1 second and a duty cycle of 1:1. The code design is as follows:
void main(void)
{
GPIO_Init(LED3_PORT,LED3_PIN,GPIO_Mode_Out_PP_High_Fast);
//Output low level - high speed 10M
GPIO_Init(LED4_PORT,LED4_PIN,GPIO_Mode_Out_PP_High_Fast);
//Output low level - high speed 10M
GPIO_Init(CNT_EN_PORT,CNT_EN_PIN,GPIO_Mode_Out_PP_High_Fast);
GPIO_Init(WAKEUP_PORT,WAKEUP_PIN,GPIO_Mode_In_FL_IT);//PE6
LCD_GLASS_Init();
LCD_GLASS_DisplayString("M74HC");
/* Enable Rising edge port PE6 for wake up conter */
//EXTI->CR2 = 0x10;
//Rising edge or download edge can
EXTI_SetPinSensitivity(EXTI_Pin_6, EXTI_Trigger_Rising);
/* Enable Interrupts */
enableInterrupts();
GPIO_ResetBits(GPIOC,GPIO_Pin_4);//Enable U3 counter
/* Infinite loop */
while (1)
{
GPIO_ToggleBits(LED3_PORT,LED3_PIN);
halt();//Enter HALT mode, external interrupt can wake up
}
}
The program starts to initialize LED3/LED4 on the board, and the LCD displays the function of the M74HC counter. PE6 is a rising edge trigger. After entering while, it enters HALT mode, the CPU is shut down, and will not execute. It can only be executed when an external interrupt occurs.
Interrupt function:
INTERRUPT_HANDLER(EXTI6_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
sim()
GPIO_ToggleBits(GPIOC,GPIO_Pin_7);
/* Clear Interrupt pending bit */
EXTI_ClearITPendingBit(EXTI_IT_Pin6);
rim()
}
The phenomenon is that LEDs 3 and 4 on the board flash alternately with a period of 1s, indicating that the CPU alternates between HALT mode and working mode.
Keywords:STM8L
Reference address:STM8L Exploration Kit Study Notes - Low Power Mode (XII)
STM8L has 5 low power consumption modes. The way to reduce power consumption can also be to reduce the system clock or turn off unused peripherals.
Today we will use U3, a 14-stage pulsating carry counter M74HC4060, to wake up the HALT mode. From the schematic diagram, we can see that the reverse connection of the output of Q14 pin is connected to the T2 analog switch to control the PE6 port. Because it passes through two inverters, the logic of Q14 is equal to the logic of PE6. The clock frequency of U3 is 30KHZ, and the pulse period of Q14 is 2 to the 14th power divided by 30KHZ, which is approximately equal to 0.5s, that is, the pulse output by Q14 is a square wave with a period of about 1 second and a duty cycle of 1:1. Therefore, the level change of PE6 is also a square wave with a period of about 1 second and a duty cycle of 1:1. The code design is as follows:
void main(void)
{
GPIO_Init(LED3_PORT,LED3_PIN,GPIO_Mode_Out_PP_High_Fast);
//Output low level - high speed 10M
GPIO_Init(LED4_PORT,LED4_PIN,GPIO_Mode_Out_PP_High_Fast);
//Output low level - high speed 10M
GPIO_Init(CNT_EN_PORT,CNT_EN_PIN,GPIO_Mode_Out_PP_High_Fast);
GPIO_Init(WAKEUP_PORT,WAKEUP_PIN,GPIO_Mode_In_FL_IT);//PE6
LCD_GLASS_Init();
LCD_GLASS_DisplayString("M74HC");
/* Enable Rising edge port PE6 for wake up conter */
//EXTI->CR2 = 0x10;
//Rising edge or download edge can
EXTI_SetPinSensitivity(EXTI_Pin_6, EXTI_Trigger_Rising);
/* Enable Interrupts */
enableInterrupts();
GPIO_ResetBits(GPIOC,GPIO_Pin_4);//Enable U3 counter
/* Infinite loop */
while (1)
{
GPIO_ToggleBits(LED3_PORT,LED3_PIN);
halt();//Enter HALT mode, external interrupt can wake up
}
}
The program starts to initialize LED3/LED4 on the board, and the LCD displays the function of the M74HC counter. PE6 is a rising edge trigger. After entering while, it enters HALT mode, the CPU is shut down, and will not execute. It can only be executed when an external interrupt occurs.
Interrupt function:
INTERRUPT_HANDLER(EXTI6_IRQHandler, 14)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
sim()
GPIO_ToggleBits(GPIOC,GPIO_Pin_7);
/* Clear Interrupt pending bit */
EXTI_ClearITPendingBit(EXTI_IT_Pin6);
rim()
}
The phenomenon is that LEDs 3 and 4 on the board flash alternately with a period of 1s, indicating that the CPU alternates between HALT mode and working mode.
Previous article:STM8L Exploration Kit Study Notes-AES Hardware Encryption (Thirteen)
Next article:STM8L Discovery Kit Study Notes - EEPROM (XI)
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- 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
Guess you like
- [Xingkong Board Python Programming Learning Main Control Board] 2: Burning System Image
- NB module problem
- [EETalk] Outlook for the development of consumer electronics interfaces - Will USB dominate the world?
- Compilation issues
- The Painful Experience of DSP Connecting to Emulator
- BleFi - BLE Wifi IOT Gateway Reference Design
- About the selection of energy storage inductor in DCDC circuit?
- [Analog Electronics Course Selection Test] + Assessment
- Matrix keyboard problem
- [Raspberry Pi Pico Review] 5. Pico drives LCD1602