STM32F4 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F4 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
Initialization and Configuration functions

Initialization and Configuration functions. More...

Functions

ErrorStatus RTC_DeInit (void)
 Deinitializes the RTC registers to their default reset values. More...
 
ErrorStatus RTC_Init (RTC_InitTypeDef *RTC_InitStruct)
 Initializes the RTC registers according to the specified parameters in RTC_InitStruct. More...
 
void RTC_StructInit (RTC_InitTypeDef *RTC_InitStruct)
 Fills each RTC_InitStruct member with its default value. More...
 
void RTC_WriteProtectionCmd (FunctionalState NewState)
 Enables or disables the RTC registers write protection. More...
 
ErrorStatus RTC_EnterInitMode (void)
 Enters the RTC Initialization mode. More...
 
void RTC_ExitInitMode (void)
 Exits the RTC Initialization mode. More...
 
ErrorStatus RTC_WaitForSynchro (void)
 Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock. More...
 
ErrorStatus RTC_RefClockCmd (FunctionalState NewState)
 Enables or disables the RTC reference clock detection. More...
 
void RTC_BypassShadowCmd (FunctionalState NewState)
 Enables or Disables the Bypass Shadow feature. More...
 

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 prescalers to minimize power consumption.
     - A 7-bit asynchronous prescaler and A 13-bit synchronous prescaler.
     - When both prescalers 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.

Note
When the Bypass Shadow is enabled the calendar value are taken directly from the Calendar counter.
Parameters
NewState,:new state of the Bypass Shadow feature. This parameter can be: ENABLE or DISABLE.
Return values
None
ErrorStatus RTC_DeInit ( void  )

Deinitializes the RTC registers to their default reset values.

Note
This function doesn't reset the RTC Clock source and RTC Backup Data registers.
Parameters
None
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC registers are deinitialized
  • ERROR: RTC registers are not deinitialized
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
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
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
ErrorStatus RTC_RefClockCmd ( FunctionalState  NewState)

Enables or disables the RTC reference clock detection.

Parameters
NewState,:new state of the RTC reference clock. This parameter can be: ENABLE or DISABLE.
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC reference clock detection is enabled
  • ERROR: RTC reference clock detection is disabled
void RTC_StructInit ( RTC_InitTypeDef RTC_InitStruct)

Fills each RTC_InitStruct member with its default value.

Parameters
RTC_InitStruct,:pointer to a RTC_InitTypeDef structure which will be initialized.
Return values
None
ErrorStatus RTC_WaitForSynchro ( void  )

Waits until the RTC Time and Date registers (RTC_TR and RTC_DR) are synchronized with RTC APB clock.

Note
The RTC Resynchronization mode is write protected, use the RTC_WriteProtectionCmd(DISABLE) before calling this function.
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.
Parameters
None
Return values
AnErrorStatus enumeration value:
  • SUCCESS: RTC registers are synchronised
  • ERROR: RTC registers are not synchronised
void RTC_WriteProtectionCmd ( FunctionalState  NewState)

Enables or disables the RTC registers write protection.

Note
All the RTC registers are write protected except for RTC_ISR[13:8], RTC_TAFCR and RTC_BKPxR.
Writing a wrong key reactivates the write protection.
The protection mechanism is not affected by system reset.
Parameters
NewState,:new state of the write protection. This parameter can be: ENABLE or DISABLE.
Return values
None