Low power consumption application of STM8L051X series RTC

Publisher:SerendipitySoulLatest update time:2019-12-19 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  GPIO_Init(GPIOA,GPIO_Pin_0,GPIO_Mode_Out_PP_Low_Slow);

  GPIO_Init(GPIOB,GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7,GPIO_Mode_Out_PP_Low_Slow);

  GPIO_Init(GPIOC,GPIO_Pin_1|GPIO_Pin_4,GPIO_Mode_Out_PP_Low_Slow);

  GPIO_Init(GPIOD,GPIO_Pin_0,GPIO_Mode_Out_PP_Low_Slow);

 /********************************************************************/  

 

  UART1_Init();

  ADC1_Config();  

  RTC_Init();

//TIM4_Config();

  ADC_Value_1 = Read_ADC_Value();

// IWDG_Config(); //Independent watchdog

  WWDG_Config(); //Window watchdog

  enableInterrupts(); //Enable total interrupt 

  printf("The System Startrn");

  AWU_RTC(600); //Set wakeup every 10 minutes

  while(1)

  {

    WWDG_SetCounter(COUNTER_INIT); //Feed the window watchdog

    RTC_Print(); //Print RTC time  

    if(Ws_Flag==1) //If it is morning time, check ADC

    {         

      ADC_Value_1 = Read_ADC_Value(); 

      ADC_Value=(ADC_Value_1*3300)/4096;      

      if(ADC_Value<2450)

      {       

          GPIO_ResetBits(GPIOC,GPIO_Pin_4);  

          printf("***Insufficient power detected, power turned off***rn");

       }

      else if(ADC_Value>=2540)

      {

          GPIO_SetBits(GPIOC,GPIO_Pin_4);

          printf("***Sufficient power, power on***rn");

      } 

      printf("ADC:%ldmvrn",ADC_Value);

    }    

    else //Turn off the power if the night time is off

    {

      GPIO_ResetBits(GPIOC,GPIO_Pin_4);

    }

    halt(); //Enter active halt mode, the program is blocked here

  }

}

Unlike STM32 and STM8, this microcontroller requires manual interrupt enablement, i.e. code enableInterrupts(); //Open the general interrupt, otherwise the alarm interrupt cannot be entered.


The alarm interrupt and wake-up interrupt share an interrupt service function as follows:


INTERRUPT_HANDLER(RTC_CSSLSE_IRQHandler,4)

{

  if(RTC_GetITStatus(RTC_IT_ALRA))//Judge the alarm interrupt flag

  {

      if(Close_Flag==1)

      {

        Time_print();

      }

      else if(Open_Flag==1)

      {

        Time_print();

      }

  }

 

  RTC_ClearITPendingBit(RTC_IT_ALRA); //Clear flag bit

  RTC->ISR2 &= (uint8_t)(~0x04);

}

For the initialization code of other peripherals, please refer to the link below:


http://bbs.21ic.com/home.php?mod=space&uid=1875788&do=thread&view=me&order=dateline&from=space&page=2

[1] [2]
Reference address:Low power consumption application of STM8L051X series RTC

Previous article:STM8L ultra-low power programming tutorial, easy to understand
Next article:STM8L052C6 low power consumption + LCD display experience sharing

Recommended ReadingLatest update time:2024-11-15 16:52

STM8L RTC Summary (1)
introduce When the battery meets the minimum power supply state of the MCU, the RTC is always in working state regardless of whether the MCU is in running, low power or restart state.  The main features are as follows: Calendar function Periodic wake-up Event triggering Pulse output Clock Source The RTC clock so
[Microcontroller]
S3C2440 test program (II) RTC display experiment
source code: void RTC_Display(void)  { U16 year ; U8 month, day ;  // week U8 hour, minute, second ; RTC_Time_Set() ;  Note: Initial date and time settings      Uart_Printf( "\nRTC TIME Display, press ESC key to exit !\n" ) ; while( Uart_GetKey() != ESC_KEY ) {  rRTCCON = 1 ;  //RTC read and write enable  year = 0x20
[Microcontroller]
ARM Real-time Clock - RTC
Introduction to Real Time Clock The Real Time Clock (RTC) can use a backup battery to work when the system is powered off. Even if the power is off, the backup battery can store time data in seconds, minutes, hours, weeks, days, months, and years. The RTC unit is connected to an external 32.768 kHz chip and has an ala
[Microcontroller]
ARM Real-time Clock - RTC
STM32, RTC periodic wakeup (wakeup) interrupt
STM32L151: int main(void) {   HAL_Init();   SystemClock_Config();   MX_GPIO_Init();     LED_ON();   MX_DMA_Init();   MX_SPI1_Init();   MX_SPI2_Init();   MX_TIM3_Init();   MX_USART2_UART_Init();   //MX_IWDG_Init();   MX_RTC_In it( );   MX_USART3_UART_Init();   MX_USART1_UART_Init();     printf("init complete...\r\n ");
[Microcontroller]
S3C2440 - RTC interrupt
The RTC (Real Time Clock) unit can be powered by the system backup battery when the system is powered off. The RTC can transfer 8-bit BCD data to the CPU through the ARM's STRB/LDRB instructions. The data includes hours, minutes, seconds, hours, days, months and years. The RTC can also perform alarm functions using an
[Microcontroller]
S3C2440 - RTC interrupt
Error in using STM32 systick timer interrupt to implement RTC working process
Development environment: keil MDK V5.10 Operating system: Windows 7 (32-bit) Target hardware: STM32F103C8 Problem description: Use the systick timer of STM32 to implement the RTC function. The specific method is to configure the systick tick timer as a tick interrupt with a time interval of 1ms, and define an RT
[Microcontroller]
2440 bare metal part 4 RTC real time clock
//******************************************************************* //manymany-2440 bare metal chapter 4 RTC real-time clock //*************************************************************** //Purpose: Master the RTC real-time clock function, display the real-time clock every second // Realize the real-time alarm fu
[Microcontroller]
STM32L151C8 periodically wakes up from standby mode (RTC Wakeup Timer)
#include "stm32l1xx.h" #include "system_stm32l1xx.h" #include "OLED.h" #include "delay.h" void RtcWakeUpConfig(void); u8 RtcInit(void); u8 RtcConfig(void); int main() {     DelayInit(); //Delay initialization     RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); //Enable PWR clock     if(PWR_GetFlagStatus(PWR_FL
[Microcontroller]
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号