SPRADI6 May 2024 F29H850TU , F29H859TU-Q1 , TMS320F2800132 , TMS320F2800133 , TMS320F2800135 , TMS320F2800137 , TMS320F2800152-Q1 , TMS320F2800153-Q1 , TMS320F2800154-Q1 , TMS320F2800155 , TMS320F2800155-Q1 , TMS320F2800156-Q1 , TMS320F2800157 , TMS320F2800157-Q1 , TMS320F28P650DH , TMS320F28P650DK , TMS320F28P650SH , TMS320F28P650SK , TMS320F28P659DH-Q1 , TMS320F28P659DK-Q1 , TMS320F28P659SH-Q1
In appliance applications, internal oscillators are usually used as clock sources. The C2000 MCU has two internal oscillators, which can be used to mutually verify the stability of the clock frequency. There are two methods for clock self-test in C2000 MCUs. One is using the HRPWM module, and the other is using the CPU Timer. Both test methods are found in the test_application project, STA_OSC_HR is for HRPWM and STA_OSC_CT is for CPU Timer.
Use the CPU Timer module to detect incorrect clock frequencies and drift between clock sources. CPU Timer2 has a programmable counter whose prescale value and clock source can be selected. The frequency relationship between selected clock and system clock can be determined by using the system clock as a reference time base. Common cause failures can be reduced by using different clock sources and different prescale values for the reference clock and measured clock.
The principle of using a CPU Timer for detection is that the system clock is usually set as the internal oscillator 2 (XTAL2), and the clock source of CPU Timer2 is switched to the internal crystal oscillator 1 (XTAL1). The system clock and CPU Timer2 are used simultaneously to measure a period of time, and the difference between the counts is compared to determine whether there is a frequency deviation in the internal oscillators. If the elapsed number of ticks is not within the designated boundaries, the function returns STL_OSC_CT_FAIL. Otherwise, the function returns STL_OSC_CT_PASS. The source code is found at f280013x\source\stl_osc_ct.c.