Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 6 | ||
---|---|---|---|
Line 593... | Line 593... | ||
593 | @verbatim |
593 | @verbatim |
594 | =============================================================================== |
594 | =============================================================================== |
595 | ##### Extended Clock Recovery System Control functions ##### |
595 | ##### Extended Clock Recovery System Control functions ##### |
596 | =============================================================================== |
596 | =============================================================================== |
597 | [..] |
597 | [..] |
598 | For devices with Clock Recovery System feature (CRS), RCC Extention HAL driver can be used as follows: |
598 | For devices with Clock Recovery System feature (CRS), RCC Extension HAL driver can be used as follows: |
599 | 599 | ||
600 | (#) In System clock config, HSI48 needs to be enabled |
600 | (#) In System clock config, HSI48 needs to be enabled |
601 | 601 | ||
602 | (#) Enable CRS clock in IP MSP init which will use CRS functions |
602 | (#) Enable CRS clock in IP MSP init which will use CRS functions |
603 | 603 | ||
604 | (#) Call CRS functions as follows: |
604 | (#) Call CRS functions as follows: |
605 | (##) Prepare synchronization configuration necessary for HSI48 calibration |
605 | (##) Prepare synchronization configuration necessary for HSI48 calibration |
606 | (+++) Default values can be set for frequency Error Measurement (reload and error limit) |
606 | (+++) Default values can be set for frequency Error Measurement (reload and error limit) |
607 | and also HSI48 oscillator smooth trimming. |
607 | and also HSI48 oscillator smooth trimming. |
608 | (+++) Macro @ref __HAL_RCC_CRS_RELOADVALUE_CALCULATE can be also used to calculate |
608 | (+++) Macro __HAL_RCC_CRS_RELOADVALUE_CALCULATE can be also used to calculate |
609 | directly reload value with target and synchronization frequencies values |
609 | directly reload value with target and synchronization frequencies values |
610 | (##) Call function @ref HAL_RCCEx_CRSConfig which |
610 | (##) Call function HAL_RCCEx_CRSConfig which |
611 | (+++) Reset CRS registers to their default values. |
611 | (+++) Reset CRS registers to their default values. |
612 | (+++) Configure CRS registers with synchronization configuration |
612 | (+++) Configure CRS registers with synchronization configuration |
613 | (+++) Enable automatic calibration and frequency error counter feature |
613 | (+++) Enable automatic calibration and frequency error counter feature |
614 | Note: When using USB LPM (Link Power Management) and the device is in Sleep mode, the |
614 | Note: When using USB LPM (Link Power Management) and the device is in Sleep mode, the |
615 | periodic USB SOF will not be generated by the host. No SYNC signal will therefore be |
615 | periodic USB SOF will not be generated by the host. No SYNC signal will therefore be |
616 | provided to the CRS to calibrate the HSI48 on the run. To guarantee the required clock |
616 | provided to the CRS to calibrate the HSI48 on the run. To guarantee the required clock |
617 | precision after waking up from Sleep mode, the LSE or reference clock on the GPIOs |
617 | precision after waking up from Sleep mode, the LSE or reference clock on the GPIOs |
618 | should be used as SYNC signal. |
618 | should be used as SYNC signal. |
619 | 619 | ||
620 | (##) A polling function is provided to wait for complete synchronization |
620 | (##) A polling function is provided to wait for complete synchronization |
621 | (+++) Call function @ref HAL_RCCEx_CRSWaitSynchronization() |
621 | (+++) Call function HAL_RCCEx_CRSWaitSynchronization() |
622 | (+++) According to CRS status, user can decide to adjust again the calibration or continue |
622 | (+++) According to CRS status, user can decide to adjust again the calibration or continue |
623 | application if synchronization is OK |
623 | application if synchronization is OK |
624 | |
624 | |
625 | (#) User can retrieve information related to synchronization in calling function |
625 | (#) User can retrieve information related to synchronization in calling function |
626 | @ref HAL_RCCEx_CRSGetSynchronizationInfo() |
626 | HAL_RCCEx_CRSGetSynchronizationInfo() |
627 | 627 | ||
628 | (#) Regarding synchronization status and synchronization information, user can try a new calibration |
628 | (#) Regarding synchronization status and synchronization information, user can try a new calibration |
629 | in changing synchronization configuration and call again HAL_RCCEx_CRSConfig. |
629 | in changing synchronization configuration and call again HAL_RCCEx_CRSConfig. |
630 | Note: When the SYNC event is detected during the downcounting phase (before reaching the zero value), |
630 | Note: When the SYNC event is detected during the downcounting phase (before reaching the zero value), |
631 | it means that the actual frequency is lower than the target (and so, that the TRIM value should be |
631 | it means that the actual frequency is lower than the target (and so, that the TRIM value should be |
632 | incremented), while when it is detected during the upcounting phase it means that the actual frequency |
632 | incremented), while when it is detected during the upcounting phase it means that the actual frequency |
633 | is higher (and that the TRIM value should be decremented). |
633 | is higher (and that the TRIM value should be decremented). |
634 | 634 | ||
635 | (#) In interrupt mode, user can resort to the available macros (__HAL_RCC_CRS_XXX_IT). Interrupts will go |
635 | (#) In interrupt mode, user can resort to the available macros (__HAL_RCC_CRS_XXX_IT). Interrupts will go |
636 | through CRS Handler (RCC_IRQn/RCC_IRQHandler) |
636 | through CRS Handler (RCC_IRQn/RCC_IRQHandler) |
637 | (++) Call function @ref HAL_RCCEx_CRSConfig() |
637 | (++) Call function HAL_RCCEx_CRSConfig() |
638 | (++) Enable RCC_IRQn (thanks to NVIC functions) |
638 | (++) Enable RCC_IRQn (thanks to NVIC functions) |
639 | (++) Enable CRS interrupt (@ref __HAL_RCC_CRS_ENABLE_IT) |
639 | (++) Enable CRS interrupt (__HAL_RCC_CRS_ENABLE_IT) |
640 | (++) Implement CRS status management in the following user callbacks called from |
640 | (++) Implement CRS status management in the following user callbacks called from |
641 | HAL_RCCEx_CRS_IRQHandler(): |
641 | HAL_RCCEx_CRS_IRQHandler(): |
642 | (+++) @ref HAL_RCCEx_CRS_SyncOkCallback() |
642 | (+++) HAL_RCCEx_CRS_SyncOkCallback() |
643 | (+++) @ref HAL_RCCEx_CRS_SyncWarnCallback() |
643 | (+++) HAL_RCCEx_CRS_SyncWarnCallback() |
644 | (+++) @ref HAL_RCCEx_CRS_ExpectedSyncCallback() |
644 | (+++) HAL_RCCEx_CRS_ExpectedSyncCallback() |
645 | (+++) @ref HAL_RCCEx_CRS_ErrorCallback() |
645 | (+++) HAL_RCCEx_CRS_ErrorCallback() |
646 | 646 | ||
647 | (#) To force a SYNC EVENT, user can use the function @ref HAL_RCCEx_CRSSoftwareSynchronizationGenerate(). |
647 | (#) To force a SYNC EVENT, user can use the function HAL_RCCEx_CRSSoftwareSynchronizationGenerate(). |
648 | This function can be called before calling @ref HAL_RCCEx_CRSConfig (for instance in Systick handler) |
648 | This function can be called before calling HAL_RCCEx_CRSConfig (for instance in Systick handler) |
649 | |
649 | |
650 | @endverbatim |
650 | @endverbatim |
651 | * @{ |
651 | * @{ |
652 | */ |
652 | */ |
653 | 653 |