1.48 CLASSB_ClockTest
Function
CLASSB_TEST_STATUS CLASSB_ClockTest(uint32_t cpu_clock_freq, uint8_t error_limit, uint16_t clock_test_rtc_cycles, bool running_context);
Summary
This self-test checks whether the CPU clock frequency is within the permissible limit.
Description
This self-test uses RTC and SysTick to measure the CPU clock frequency. The RTC is clocked at 32768 Hz from the XOSC32K and CPU clock can be from any other high frequency oscillator. If the CPU clock frequency is within specified error limit, it returns PASS. The test duration is defined by the value of rtc_cycles. The RTC is configured to take clock from an external 32.768 kHz accurate crystal.
Precondition
None.
Parameters
cpu_clock_freq - Expected CPU clock frequency.
error_limit - Permissible error limit (eg; 5 means +-5 percent).
clock_test_rtc_cycles - The test duration in terms of RTC cycles.
running_context - False for startup test. True for run-time test.
Returns
CLASSB_TEST_STATUS - Status of the test.
Example
CLASSB_TEST_STATUS classb_test_status = CLASSB_TEST_NOT_EXECUTED; // Perform run-time test of the CPU clock classb_test_status = CLASSB_ClockTest(120000000, 5, 500, true);
Remarks
This self-test can be used during startup as well as run-time. This self-test shall be used only if there is an external 32.768 kHz accurate crystal connected to the XOSC32K of the microcontroller.