Oscillator CPU Timer API Functions

Module Details

The code for this module is contained in source/stl_osc_ct.c, with include/stl_osc_ct.h containing the API declarations for use by applications.

Note that the Dual-Clock Compare (DCC) hardware diagnostic is the recommended method for Clock checks. However, the STL_OSC_CT module is provided for scenarios where DCC may not be used, such as all available DCC instances being already in use. See your device technical reference manual and device DCC examples in C2000Ware for more details about using DCC.

Error Injection

To inject an error to be detected by STL_OSC_CT_startTest() and STL_OSC_CT_stopTest(), you can do one of the following:

  • Set maxCount and minCount to values so that the Timer 2 counter will be out of range.

  • Set the prescaler so that the Timer 2 counter will not be in the minCount/maxCount range.

Module Details

group stl_osc_ct

Defines

STL_OSC_CT_FAIL 1U
STL_OSC_CT_PASS 0U
STL_OSC_CT_PERIOD 0xFFFFFFFFU

Typedefs

typedef STL_OSC_CT_Obj *STL_OSC_CT_Handle

Defines the OSC Timer 2 test handle.

Functions

void STL_OSC_CT_startTest(const STL_OSC_CT_Handle oscTimer2Handle)

Starts CPU Timer 2 to test the oscillator source.

This function disables CPU Timer 2 interrupts, configures the CPU Timer 2 to use the specified clock source and prescaler, starts the timer, and then returns.

Parameters
  • oscTimer2Handle: is a pointer to the Oscillator Timer 2 object.

The user should configure the PLL and CPU Timer with independent clock sources.

The user must preserve and restore the registers modified by this function. The following CPU Timer 2 and System Control registers are modified by the function.

  • TCR

  • PRD

  • TPRH

  • TPR

  • TMR2CLKCTL

Note

When CPUTIMER_CLOCK_SOURCE_SYS is selected as the clockSource, the prescaler is bypassed.

Return

None.

uint16_t STL_OSC_CT_stopTest(const STL_OSC_CT_Handle oscTimer2Handle)

Stops CPU Timer 2 and checks the elapsed time.

This function stops CPU Timer 2 and then compares the number of ticks that have elapsed with the min and max boundaries. This function is intended to be used in combination with

STL_OSC_CT_startTest() to perform a periodic test of the oscillator source.
Parameters
  • oscTimer2Handle: is a pointer to the Oscillator Timer 2 object.

Return

If the elapsed number of ticks is not within the min and max boundaries, the function returns STL_OSC_CT_FAIL. Otherwise, it returns STL_OSC_CT_PASS.

struct STL_OSC_CT_Obj
#include <stl_osc_ct.h>

Defines the OSC Timer 2 test object.