iLLD_TC27xC  1.0
How to use the CCU6 TIMER Interface driver?
Collaboration diagram for How to use the CCU6 TIMER Interface driver?:

The TIMER interface driver provides a default CCU6 configuration for runnung the selected timer block.

User can select the various configuration options that hardware allows

In the following sections it will be described, how to integrate the driver into the application framework.

Preparation

Include Files

Include following header file into your C code:

Variables

Declare the TIMER handle as global variable in your C code:

// used globally
static IfxCcu6_Timer timer;

Interrupt Handler Installation

See also How to define Interrupts?

Define priority for the Interrrupt handler. This is normally done in the Ifx_IntPrioDef.h file:

// priorities are normally defined in Ifx_IntPrioDef.h
#define IFX_INTPRIO_CCU6 1

Add the interrupt service routine to your C code.

IFX_INTERRUPT(ccu60ISR_Timer, 0, IFX_INTPRIO_CCU6)
{
//user code
}

Finally install the interrupt handlers in your initialisation function:

// install interrupt handlers
IfxCpu_Irq_installInterruptHandler(&ccu60ISR_Timer, IFX_INTPRIO_CCU6);

Module Initialisation

The module initialisation can be done in the same function. Here an example:

// create configuration
IfxCcu6_Timer_initModuleConfig(&timerConfig, &MODULE_CCU60);
// configure the frequency of the timer in case of internal start
// this frequency will be set for the timer block selected later
timerConfig.base.frequency = 400000;
// configure the period of the timer
timerConfig.base.period = 100;
// configure the waiting time in case of delayed T13 start in sync with T12
timerConfig.base.waitingTime = 0;
// select the timer that needs to be started
timerConfig.timer = IfxCcu6_TimerId_t12;
// select the synchronous operation if both timers need to be start at the same time
// previous selection of timer block can be ignored in this mode
timerConfig.synchronousOperation = TRUE;
// configure the clock for internal mode
// configure the selcted timer block
timerConfig.timer12.counterValue = 0;
// configure the interrupts
timerConfig.interrupt.priority = IFX_INTRPRIO_CCU6;
// configure input and output triggers
// initialize the module
IfxCcu6_Timer_initModule(&timer, &timerConfig);

The Timer is ready for use now!

Control

The TIMER driver provides simple to use timer Control functions

This means: In addition to start and stop a single timer, you can start and stop both the timer blocks at the same time you can also run the timer in single shot mode and finally you an manually make the timer count each step

Start the timer

Stop the timer

Start both the timers synchronously, when the synchronousOperation mode is selected in the configuration

Stop both the timers synchronously, when the synchronousOperation mode is selected in the configuration

Start the selected timer in single shot mode

Make the timer count each step manually

for (i=0; i<50; i++)
{
}