STM8L15x Standard Peripherals Drivers: Initialization and Configuration functions

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

Initialization and Configuration functions

Initialization and Configuration functions. More...

Functions

void RTC_BypassShadowCmd (FunctionalState NewState)
 Enables or Disables the Bypass Shadow feature.
ErrorStatus RTC_DeInit (void)
 Deinitializes the RTC registers to their default reset values.
ErrorStatus RTC_EnterInitMode (void)
 Enters the RTC Initialization mode.
void RTC_ExitInitMode (void)
 Exits the RTC Initialization mode.
ErrorStatus RTC_Init (RTC_InitTypeDef *RTC_InitStruct)
 Initializes the RTC registers according to the specified parameters in RTC_InitStruct.
void RTC_RatioCmd (FunctionalState NewState)
 Enables or Disables the RTC Ratio.
void RTC_StructInit (RTC_InitTypeDef *RTC_InitStruct)
 Fills each RTC_InitStruct member with its default value Hour format = 24h / Prescalers configured to their reset values.
ErrorStatus RTC_WaitForSynchro (void)
 Waits until the RTC Calendar registers (Time and Date) are synchronized with RTC clock.
void RTC_WriteProtectionCmd (FunctionalState NewState)
 Enables or disables the RTC registers write protection.

Detailed Description

Initialization and Configuration functions.

 ===============================================================================
                 Initialization and Configuration functions
 ===============================================================================  

  This section provide functions allowing to initialize and configure the RTC
  Prescaler (Synchronous and Asynchronous), RTC Hour format, disable RTC registers
  Write protection, enter and exit the RTC initialization mode, RTC registers
  synchronization check and reference clock detection enable.
  
  1. The RTC Prescaler is programmed to generate the RTC 1Hz time base. It is
     split into 2 programmable prescaler to minimize power consumption.
     - A 7-bit asynchronous prescaler and A 13-bit or 15-bit synchronous 
       prescaler depending to density of the mcu package.
     - When both prescaler are used, it is recommended to configure the 
       asynchronous prescaler to a high value to minimize consumption.

  2. All RTC registers are Write protected. Writing to the RTC registers
     is enabled by writing a key into the Write Protection register, RTC_WPR.

  3. To Configure the RTC Calendar, user application should enter initialization
     mode. In this mode, the Calendar counter is stopped and its value can be 
     updated. When the initialization sequence is complete, the Calendar restarts 
     counting after 4 RTCCLK cycles.

  4. To read the Calendar through the shadow registers after Calendar initialization,
     Calendar update or after wakeup from low power modes the software must first 
     clear the RSF flag. The software must then wait until it is set again before 
     reading the Calendar, which means that the Calendar registers have been 
     correctly copied into the RTC_TR and RTC_DR shadow registers.
     The RTC_WaitForSynchro() function implements the above software sequence 
     (RSF clear and RSF check).


Function Documentation

void RTC_BypassShadowCmd ( FunctionalState  NewState)

Enables or Disables the Bypass Shadow feature.

Parameters:
NewState,:new state of the Bypass Shadow feature. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 592 of file stm8l15x_rtc.c.

References DISABLE, IS_FUNCTIONAL_STATE, RTC, and RTC_CR1_BYPSHAD.

ErrorStatus RTC_EnterInitMode ( void  )

Enters the RTC Initialization mode.

Note:
The RTC Initialization mode is write protected, use the RTC_WriteProtectionCmd(DISABLE) before calling this function.
Parameters:
None
Return values:
AnErrorStatus enumeration value:
  • SUCCESS: RTC is in Init mode
  • ERROR: RTC is not in Init mode

Definition at line 452 of file stm8l15x_rtc.c.

References ERROR, INITF_TIMEOUT, RESET, RTC, RTC_ISR1_INIT, RTC_ISR1_INITF, and SUCCESS.

Referenced by RTC_DeInit(), RTC_Init(), RTC_SetDate(), and RTC_SetTime().

void RTC_ExitInitMode ( void  )

Exits the RTC Initialization mode.

Note:
When the initialization sequence is complete, the Calendar restarts counting after 4 RTCCLK cycles.
The RTC Initialization mode is write protected, use the RTC_WriteProtectionCmd(DISABLE) before calling this function.
Parameters:
None
Return values:
None

Definition at line 492 of file stm8l15x_rtc.c.

References RTC, and RTC_ISR1_INIT.

ErrorStatus RTC_Init ( RTC_InitTypeDef RTC_InitStruct)

Initializes the RTC registers according to the specified parameters in RTC_InitStruct.

Parameters:
RTC_InitStruct,:pointer to a RTC_InitTypeDef structure that contains the configuration information for the RTC peripheral.
Note:
The RTC Prescaler register is write protected and can be written in initialization mode only.
Return values:
AnErrorStatus enumeration value:
  • SUCCESS: RTC registers are initialized
  • ERROR: RTC registers are not initialized

Definition at line 353 of file stm8l15x_rtc.c.

References ERROR, IS_RTC_ASYNCH_PREDIV, IS_RTC_HOUR_FORMAT, IS_RTC_SYNCH_PREDIV, RTC, RTC_InitTypeDef::RTC_AsynchPrediv, RTC_CR1_FMT, RTC_EnterInitMode(), RTC_InitTypeDef::RTC_HourFormat, RTC_ISR1_INIT, RTC_InitTypeDef::RTC_SynchPrediv, and SUCCESS.

void RTC_RatioCmd ( FunctionalState  NewState)

Enables or Disables the RTC Ratio.

Parameters:
NewState,:new state of the Ratio feature. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 562 of file stm8l15x_rtc.c.

References DISABLE, IS_FUNCTIONAL_STATE, RTC, and RTC_CR1_RATIO.

void RTC_StructInit ( RTC_InitTypeDef RTC_InitStruct)

Fills each RTC_InitStruct member with its default value Hour format = 24h / Prescalers configured to their reset values.

Parameters:
RTC_InitStruct,:pointer to a RTC_InitTypeDef structure which will be initialized.
Return values:
None

Definition at line 404 of file stm8l15x_rtc.c.

References RTC_APRER_RESET_VALUE, RTC_InitTypeDef::RTC_AsynchPrediv, RTC_InitTypeDef::RTC_HourFormat, RTC_HourFormat_24, RTC_SPRERL_RESET_VALUE, and RTC_InitTypeDef::RTC_SynchPrediv.

ErrorStatus RTC_WaitForSynchro ( void  )

Waits until the RTC Calendar registers (Time and Date) are synchronized with RTC clock.

Note:
This function is meaningless when BAYPASS feature is enabled in RTC_CR1 register.
To read the Calendar through the shadow registers after Calendar initialization, Calendar update or after wakeup from low power modes the software must first clear the RSF flag. The software must then wait until it is set again before reading the Calendar (if not yet done), which means that the Calendar registers have been correctly copied into the RTC_TRx and RTC_DRx shadow registers.
RTC_SetTime() and RTC_SetDate() functions call RTC_WaitForSynchro() function after updating the Calendar. In Run mode, User can use RTC_GetDate(), RTC_GetTime() and/or RTC_GetSubSecond() without need to call RTC_WaitForSynchro() function. After waking up from low power mode, this function must be called before calling RTC_GetDate(), RTC_GetTime() or RTC_GetSubSecond() functions.
Parameters:
None
Return values:
AnErrorStatus enumeration value:
  • SUCCESS: RTC registers are synchronized
  • ERROR: RTC registers are not synchronized

Definition at line 521 of file stm8l15x_rtc.c.

References ERROR, RESET, RSF_TIMEOUT, RTC, RTC_ISR1_INIT, RTC_ISR1_RSF, and SUCCESS.

Referenced by RTC_DeInit(), RTC_SetDate(), and RTC_SetTime().

void RTC_WriteProtectionCmd ( FunctionalState  NewState)

Enables or disables the RTC registers write protection.

Parameters:
NewState,:new state of the write protection. This parameter can be: ENABLE or DISABLE.
Note:
Writing a wrong key reactivates the write protection.
The protection mechanism is not affected by system reset.
Return values:
None

Definition at line 424 of file stm8l15x_rtc.c.

References DISABLE, IS_FUNCTIONAL_STATE, RTC, RTC_WPR_DisableKey1, RTC_WPR_DisableKey2, and RTC_WPR_EnableKey.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com