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

The TPWM interface driver provides a default CCU6 configuration for PWM modulation output through 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 TPWM handle as global variable in your C code:

// used globally
static IfxCcu6_TPwm tPwm;

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_TPwm, 0, IFX_INTPRIO_CCU6)
{
//user code
}

Finally install the interrupt handlers in your initialisation function:

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

Module Initialisation

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

// create configuration
IfxCcu6_TPwm_initModuleConfig(&tPwmConfig, &MODULE_CCU60);
// configure the frequency of the timer in case of internal start
// this frequency will be set for the timer block selected later
tPwmConfig.base.frequency = 400000;
// configure the period of the timer
tPwmConfig.base.period = 100;
// configure the waiting time in case of delayed T13 start in sync with T12
tPwmConfig.base.waitingTime = 20;
// select the active state of the output
// select the timer through which PWM is to be generated
// configure the clock for internal mode
// configure the selcted timer block
tPwmConfig.timer13.counterValue = 0;
tPwmConfig.timer13.compareValue = 100;
// configure the syncronisation, in case of sync start with T12
//select the channel out for modulation
// pin configuration
const IfxCcu6_TPwm_Pins pins = {
NULL, // CC60Out pin not used
NULL, // CC61Out pin not used
NULL, // CC62Out pin not used
NULL, // COUT60 pin not used
NULL, // COUT61 pin not used
NULL, // COUT62 pin not used
};
tPwmConfig.pins = &pins;
// configure the interrupts
tPwmConfig.interrupt.priority = IFX_INTPRIO_CCU6;
// configure input and output triggers
// initialize the module
IfxCcu6_TPwm_initModule(&tPwm, &tPwmConfig);

The TPWM is ready for use now!

Modulation Control

The TPWM driver provides simple to use Modulation Control functions

This means: you can start, stop, pause and resume the modulation once the module is initialised with the appropriate configuration

Start the modulation

Stop the modulation

Pause the modulation

Resume the modulation