STM8L Exploration Kit Study Notes - Low Power Mode (XII)

Publisher:RadiantGlowLatest update time:2015-12-21 Source: eefocusKeywords:STM8L Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
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)

Previous article:STM8L Exploration Kit Study Notes-AES Hardware Encryption (Thirteen)
Next article:STM8L Discovery Kit Study Notes - EEPROM (XI)

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号