TUKS MCU Introductory course / TUKS-COURSE-TIMER
Embed: (wiki syntax)

« Back to documentation index

Extended Clock Recovery System Control functions

Extended Clock Recovery System Control functions
[RCCEx Exported Functions]

Extended Clock Recovery System Control functions. More...

Functions

void HAL_RCCEx_CRSConfig (RCC_CRSInitTypeDef *pInit)
 Start automatic synchronization for polling mode.
void HAL_RCCEx_CRSSoftwareSynchronizationGenerate (void)
 Generate the software synchronization event.
void HAL_RCCEx_CRSGetSynchronizationInfo (RCC_CRSSynchroInfoTypeDef *pSynchroInfo)
 Return synchronization info.
uint32_t HAL_RCCEx_CRSWaitSynchronization (uint32_t Timeout)
 Wait for CRS Synchronization status.
void HAL_RCCEx_CRS_IRQHandler (void)
 Handle the Clock Recovery System interrupt request.
__weak void HAL_RCCEx_CRS_SyncOkCallback (void)
 RCCEx Clock Recovery System SYNCOK interrupt callback.
__weak void HAL_RCCEx_CRS_SyncWarnCallback (void)
 RCCEx Clock Recovery System SYNCWARN interrupt callback.
__weak void HAL_RCCEx_CRS_ExpectedSyncCallback (void)
 RCCEx Clock Recovery System Expected SYNC interrupt callback.
__weak void HAL_RCCEx_CRS_ErrorCallback (uint32_t Error)
 RCCEx Clock Recovery System Error interrupt callback.

Detailed Description

Extended Clock Recovery System Control functions.

 ===============================================================================
                ##### Extended Clock Recovery System Control functions  #####
 ===============================================================================
    [..]
      For devices with Clock Recovery System feature (CRS), RCC Extention HAL driver can be used as follows:

      (#) In System clock config, HSI48 needs to be enabled

      (#) Enable CRS clock in IP MSP init which will use CRS functions

      (#) Call CRS functions as follows:
          (##) Prepare synchronization configuration necessary for HSI48 calibration
              (+++) Default values can be set for frequency Error Measurement (reload and error limit)
                        and also HSI48 oscillator smooth trimming.
              (+++) Macro __HAL_RCC_CRS_RELOADVALUE_CALCULATE can be also used to calculate 
                        directly reload value with target and sychronization frequencies values
          (##) Call function HAL_RCCEx_CRSConfig which
              (+++) Resets CRS registers to their default values.
              (+++) Configures CRS registers with synchronization configuration 
              (+++) Enables automatic calibration and frequency error counter feature
           Note: When using USB LPM (Link Power Management) and the device is in Sleep mode, the
           periodic USB SOF will not be generated by the host. No SYNC signal will therefore be
           provided to the CRS to calibrate the HSI48 on the run. To guarantee the required clock
           precision after waking up from Sleep mode, the LSE or reference clock on the GPIOs
           should be used as SYNC signal.

          (##) A polling function is provided to wait for complete synchronization
              (+++) Call function HAL_RCCEx_CRSWaitSynchronization()
              (+++) According to CRS status, user can decide to adjust again the calibration or continue
                        application if synchronization is OK
              
      (#) User can retrieve information related to synchronization in calling function
            HAL_RCCEx_CRSGetSynchronizationInfo()

      (#) Regarding synchronization status and synchronization information, user can try a new calibration
           in changing synchronization configuration and call again HAL_RCCEx_CRSConfig.
           Note: When the SYNC event is detected during the downcounting phase (before reaching the zero value), 
           it means that the actual frequency is lower than the target (and so, that the TRIM value should be 
           incremented), while when it is detected during the upcounting phase it means that the actual frequency 
           is higher (and that the TRIM value should be decremented).

      (#) In interrupt mode, user can resort to the available macros (__HAL_RCC_CRS_XXX_IT). Interrupts will go 
          through CRS Handler (CRS_IRQn/CRS_IRQHandler)
              (++) Call function HAL_RCCEx_CRSConfig()
              (++) Enable CRS_IRQn (thanks to NVIC functions)
              (++) Enable CRS interrupt (__HAL_RCC_CRS_ENABLE_IT)
              (++) Implement CRS status management in the following user callbacks called from 
                   HAL_RCCEx_CRS_IRQHandler():
                   (+++) HAL_RCCEx_CRS_SyncOkCallback()
                   (+++) HAL_RCCEx_CRS_SyncWarnCallback()
                   (+++) HAL_RCCEx_CRS_ExpectedSyncCallback()
                   (+++) HAL_RCCEx_CRS_ErrorCallback()

      (#) To force a SYNC EVENT, user can use the function HAL_RCCEx_CRSSoftwareSynchronizationGenerate().
          This function can be called before calling HAL_RCCEx_CRSConfig (for instance in Systick handler)
            

Function Documentation

__weak void HAL_RCCEx_CRS_ErrorCallback ( uint32_t  Error )

RCCEx Clock Recovery System Error interrupt callback.

Parameters:
ErrorCombination of Error status. This parameter can be a combination of the following values:

  • RCC_CRS_SYNCERR
  • RCC_CRS_SYNCMISS
  • RCC_CRS_TRIMOVF
Return values:
none

Definition at line 2349 of file stm32l4xx_hal_rcc_ex.c.

__weak void HAL_RCCEx_CRS_ExpectedSyncCallback ( void   )

RCCEx Clock Recovery System Expected SYNC interrupt callback.

Return values:
none

Definition at line 2333 of file stm32l4xx_hal_rcc_ex.c.

void HAL_RCCEx_CRS_IRQHandler ( void   )

Handle the Clock Recovery System interrupt request.

Return values:
None

Definition at line 2246 of file stm32l4xx_hal_rcc_ex.c.

__weak void HAL_RCCEx_CRS_SyncOkCallback ( void   )

RCCEx Clock Recovery System SYNCOK interrupt callback.

Return values:
none

Definition at line 2311 of file stm32l4xx_hal_rcc_ex.c.

__weak void HAL_RCCEx_CRS_SyncWarnCallback ( void   )

RCCEx Clock Recovery System SYNCWARN interrupt callback.

Return values:
none

Definition at line 2322 of file stm32l4xx_hal_rcc_ex.c.

void HAL_RCCEx_CRSConfig ( RCC_CRSInitTypeDef *  pInit )

Start automatic synchronization for polling mode.

Parameters:
pInitPointer on RCC_CRSInitTypeDef structure
Return values:
None

Definition at line 2078 of file stm32l4xx_hal_rcc_ex.c.

void HAL_RCCEx_CRSGetSynchronizationInfo ( RCC_CRSSynchroInfoTypeDef *  pSynchroInfo )

Return synchronization info.

Parameters:
pSynchroInfoPointer on RCC_CRSSynchroInfoTypeDef structure
Return values:
None

Definition at line 2130 of file stm32l4xx_hal_rcc_ex.c.

void HAL_RCCEx_CRSSoftwareSynchronizationGenerate ( void   )

Generate the software synchronization event.

Return values:
None

Definition at line 2120 of file stm32l4xx_hal_rcc_ex.c.

uint32_t HAL_RCCEx_CRSWaitSynchronization ( uint32_t  Timeout )

Wait for CRS Synchronization status.

Parameters:
TimeoutDuration of the timeout
Note:
Timeout is based on the maximum time to receive a SYNC event based on synchronization frequency.
If Timeout set to HAL_MAX_DELAY, HAL_TIMEOUT will be never returned.
Return values:
Combinationof Synchronization status This parameter can be a combination of the following values:

  • RCC_CRS_TIMEOUT
  • RCC_CRS_SYNCOK
  • RCC_CRS_SYNCWARN
  • RCC_CRS_SYNCERR
  • RCC_CRS_SYNCMISS
  • RCC_CRS_TRIMOVF

Definition at line 2163 of file stm32l4xx_hal_rcc_ex.c.