DCC

The Dual Clock Comparator (DCC) is used to determine the accuracy of a clock signal during the time executaion of an application. The DCC measure the frequency of a selectable clock sources using another input clock as a reference. The clock sources as well as the accuracy are programmed by the application.

The DCC can also be configured to operate in single-shot or continuous mode. In single-shot mode, DCC performs a one-time countdown where DCC stops operation when the counters reach 0. A completion interrupt is raised and the status can be checked. In continuous mode, DCC reloads both counts with the seed value upon completion without error. In case of an error, an ESM error event is raised.

Features Supported

The DCC module provides the following functionality:

  • Ability to configure a DCC instance

  • Ability to verify the configuration of the DCC instance

  • Ability to enable a DCC instance

  • Ability to disable a DCC instance

  • Ability to query the status of a DCC instance including current configuration, error information, interrupt status, and counter values

  • Ability to clear the pending interrupt(s)

  • Ability to readback the DCC static registers

Errors detected by the DCC module during operation are reported via ESM error (application will receive via ESM application callback).

SysConfig Features

  • None

Features NOT Supported

  • None

Important Usage Guidelines

  • The Input Source clock mapping for each DCC instance can be found in the DCC section of the TRM

Example Usage

The following shows an example of SDL DCC API usage by the application.

Include the below file to access the APIs

#include <sdl/sdl_dcc.h>

Initialize the ESM to report DCC errors

SDL_ESM_config DCC_Test_esmInitConfig_MCU =
{
    .esmErrorConfig = {0u, 3u}, /* Self test error config - not used in this test*/
    .enableBitmap = {0x00000007u, 0x00000020u, 0x00000000u},
    /*                        ^           ^                            */
    /*                        Main ESM    MCU DCC0 event enabled       */
    /**< Enabling Main domain ESM output and MCU Domain DCC events     */

    .priorityBitmap = {0x0000003u, 0x00000020u, 0x00000000u},
    /**< All events high priority: except low-priority Main ESM output */

    .errorpinBitmap = {0x00000003u, 0x00000020u, 0x00000000u},
    /**< All high priority events to error pin */
};

SDL_ECC_init(SDL_ESM_INST_MCU_ESM0, &DCC_Test_esmInitConfig_MCU, SDL_ESM_applicationCallbackFunction, NULL);

Configure MCU DCC Instance 0 seed values and clocks

SDL_DCC_Config configParams;

/* Select Input0 to be CLOCK0[2] */
configParams.clk0Src = SDL_DCC_CLK0_SRC_CLOCK0_2;
/* Select Input1 to be CLKSRC2 */
configParams.clk1Src = SDL_DCC_CLK1_SRC_CLOCKSRC2;

/* Not shown:
 * Determine the clock frequencies for the sources
 * Figure out the seed values for successful completion
 * Check DCC example code for reference
 */

/* Assign the seed values for the clock selections */
configParams->clk0Seed = clk0_seed_value;
configParams->clk1Seed = clk1_seed_value;
configParams->clk0ValidSeed = clk0_valid_seed_value;

retVal = SDL_DCC_configure(SDL_DCC_INST_MCU_DCC0, &configParams);

Configure MCU DCC Instance 0 for continuous mode

/* Select continuous mode */
configParams.mode    = SDL_DCC_MODE_CONTINUOUS;

Or, configure the MCU DCC Instance 0 for single-shot mode.

/* Select continuous mode */
configParams.mode    = SDL_DCC_MODE_SINGLE_SHOT_2;

retVal = SDL_DCC_configure(SDL_DCC_INST_MCU_DCC0, &configParams);

If configuring single-shot mode, also register and enablei the done interrupt. In single-shot mode, the completion (Done) interrupt will happen at the end of the test if there are no errors. If error happens, then ESM interrupt will occur as well as the DCC error interrupt.

int32_t                 status = SystemP_SUCCESS;
HwiP_Params             hwiPrms;

/* Register interrupt */
HwiP_Params_init(&hwiPrms);
hwiPrms.intNum      = APP_DCC_INTR_NUM;
hwiPrms.callback    = &SDL_DCCAppDoneIntrISR;
status              = HwiP_construct(&gDCCHwiObject, &hwiPrms);

/* Enable the Done interrupt for DCC instance */
SDL_DCC_enableIntr(SDL_DCC_INST_MCU_DCC0, SDL_DCC_INTERRUPT_DONE);

The done interrupt handler should clear the interrupt

static void SDL_DCCAppDoneIntrISR(void *arg)
{
    SDL_DCC_clearIntr(SDL_DCC_INST_MCU_DCC0, SDL_DCC_INTERRUPT_DONE);
}

Enable DCC Instance

SDL_DCC_enable(SDL_DCC_INST_MCU_DCC0);

API Reference

DCC Operation Mode

SDL_DCC_MODE_SINGLE_SHOT_1

Stop counting when counter0 and valid0 both reach zero

SDL_DCC_MODE_SINGLE_SHOT_2

Stop counting when counter1 reaches zero

SDL_DCC_MODE_CONTINUOUS

Continuously repeat (until error)

typedef uint32_t SDL_DCC_Mode

Enum to select the DCC Operation Mode. DCC can either operate in single shot or continuous mode.

DCC Clock source of COUNT0

SDL_DCC_CLK0_SRC_CLOCK0_0

SYS_CLK1 is selected as source for COUNT0

SDL_DCC_CLK0_SRC_CLOCK0_1

SYS_CLK2 is selected as source for COUNT0

SDL_DCC_CLK0_SRC_CLOCK0_2

XREF_CLK is selected as source for COUNT0

SDL_DCC_CLK0_SRC_CLOCK0_3

FICLK is selected as source for COUNT0

typedef uint32_t SDL_DCC_ClkSrc0

Enum to select the COUNT0 clock source.

DCC Clock source of COUNT1

SDL_DCC_CLK1_SRC_CLOCK1

TEST_CLK1 is selected as source for COUNT1

SDL_DCC_CLK1_SRC_CLOCKSRC0

TEST_CLK0 is selected as source for COUNT1

SDL_DCC_CLK1_SRC_CLOCKSRC1

TEST_CLK1 is selected as source for COUNT1

SDL_DCC_CLK1_SRC_CLOCKSRC2

TEST_CLK2 is selected as source for COUNT1

SDL_DCC_CLK1_SRC_CLOCKSRC3

TEST_CLK3 is selected as source for COUNT1

SDL_DCC_CLK1_SRC_CLOCKSRC4

TEST_CLK4 is selected as source for COUNT1

SDL_DCC_CLK1_SRC_CLOCKSRC5

TEST_CLK5 is selected as source for COUNT1

SDL_DCC_CLK1_SRC_CLOCKSRC6

TEST_CLK6 is selected as source for COUNT1

SDL_DCC_CLK1_SRC_CLOCKSRC7

TEST_CLK7 is selected as source for COUNT1

SDL_DCC_CLK1_SRC_FICLK

FICLK is selected as source for COUNT1

typedef uint32_t SDL_DCC_ClkSrc1

Enum to select the COUNT1 clock source.

DCC Interrupt type

SDL_DCC_INTERRUPT_ERR

The error signal

SDL_DCC_INTERRUPT_DONE

Done interrupt signal

typedef uint32_t SDL_DCC_IntrType

Enum for DCC interrupts.

Defines

DCC_SRC0_COUNT_MAX

Macro defines maximum value of count for clock source 0.

DCC_SRC0_VALID_MAX

Macro defines maximum value of valid count for clock source 0.

DCC_SRC1_COUNT_MAX

Macro defines maximum value of count for clock source 1.

DCC_MIN_CLK0_VLD_SEED
SDL_DCC_CLK0_SRC_NUM

The number of valid Clk0 Src options.

SDL_DCC_CLK1_SRC_NUM

The number of valid clk1 Src options.

SDL_DCC_MODES_NUM

The number of valid mode options.

Functions

int32_t SDL_DCC_configure(SDL_DCC_Inst instance, const SDL_DCC_Config *pConfig)

This API is used to configure DCC module.

NOTE: If the value of ‘seedValid0’ is less then 4 then it will programmed as 4. Since minimum programmable value of the ‘seedValid0’ is 4.

Parameters:
  • instance – Holds the instance for DCC module.

  • pConfig – pointer to the DCC config structure

int32_t SDL_DCC_verifyConfig(SDL_DCC_Inst instance, const SDL_DCC_Config *pConfig)

This API is used to verify the configuration for DCC module.

Parameters:
  • instance – Holds the instance for DCC module.

  • pConfig – pointer to the DCC config structure

int32_t SDL_DCC_enable(SDL_DCC_Inst instance)

This API is used to enable the DCC module.

Parameters:

instance – Holds the instance for DCC module.

int32_t SDL_DCC_disable(SDL_DCC_Inst instance)

This API is used to disable the DCC module.

Parameters:

instance – Holds the instance for DCC module.

int32_t SDL_DCC_getStatus(SDL_DCC_Inst instance, SDL_DCC_Status *pStatus)

This API is used to get the stauts of DCC module.

Parameters:
  • instance – Holds the instance for DCC module.

  • pStatus – pointer to the SDL_DCC_status structure

int32_t SDL_DCC_enableIntr(SDL_DCC_Inst instance, SDL_DCC_IntrType intr)

This API is used to Enable the interrupts.

Parameters:
  • instance – Holds the instance for DCC module.

  • intr – Interrupts to be enabled.

int32_t SDL_DCC_disableIntr(SDL_DCC_Inst instance, SDL_DCC_IntrType intr)

This API is used to Disable the interrupts.

Parameters:
  • instance – Holds the instance for DCC module.

  • intr – Interrupts to be enabled.

int32_t SDL_DCC_clearIntr(SDL_DCC_Inst instance, SDL_DCC_IntrType intr)

This API is used to clear the interrupts.

Parameters:
  • instance – Holds the instance for DCC module.

  • intr – Interrupts to disable.

int32_t SDL_DCC_getStaticRegs(SDL_DCC_Inst instance, SDL_DCC_StaticRegs *pStaticRegs)

This API is used to get the value of static registers for DCC module.

Parameters:
  • instance – Holds the instance for DCC module.

  • pStaticRegs – Pointer to the SDL_DCC_StaticRegs structure.

struct SDL_DCC_Config
#include <sdl_dcc.h>

Structure containing parameters for DCC module configuration.

Public Members

SDL_DCC_Mode mode

Mode of operation for DCC module. Refer enum SDL_DCC_mode

SDL_DCC_ClkSrc0 clk0Src

Clock source for COUNT0 i.e. reference clock. Refer enum SDL_DCC_clkSrc0

SDL_DCC_ClkSrc1 clk1Src

Clock source for COUNT1 i.e. clock signal to be tested. Refer enum SDL_DCC_ClkSrc1.

uint32_t clk0Seed

Preload value/seed value for COUNT0

uint32_t clk0ValidSeed

Preload value/seed value for VALID0

uint32_t clk1Seed

Preload value/seed value for COUNT1

struct SDL_DCC_Status
#include <sdl_dcc.h>

Structure containing DCC status.

Public Members

bool doneIntr
bool errIntr
SDL_DCC_Config config
uint32_t clk0Cnt
uint32_t clk0Valid
uint32_t clk1Cnt
struct SDL_DCC_StaticRegs
#include <sdl_dcc.h>

Structure containing DCC Static Registers.

Public Members

uint32_t DCC_REV
uint32_t DCC_CNTSEED0
uint32_t DCC_VALIDSEED0
uint32_t DCC_CNTSEED1
uint32_t DCC_CLKSRC1
uint32_t DCC_CLKSRC0