iLLD_TC26xB  1.0
How to use the GTM TOM PWM Driver
Collaboration diagram for How to use the GTM TOM PWM Driver:

This interface allows to generate simple PWM signal on a TOM out put and can generate interrupts if enabled. this output can also be routed to port pin if required.

Preparation

Include Files

Include following header file into your C code:

Variables

define global variables if necessary

Ifx_GTM *gtm = &MODULE_GTM;
#define TOM0_CH0_PRIO 10

Interrupts

define Interrupts if needed

IFX_INTERRUPT(TOM0Ch0_ISR, 0, TOM0_CH0_PRIO)
{}

Initialization

// install interrupt handlers
IfxCpu_Irq_installInterruptHandler (TOM0Ch0_ISR, TOM0_CH0_PRIO);
// enable GTM clock
{
// Enables the GTM
// Set the global clock frequency to the max
IfxGtm_Cmu_setGclkFrequency(gtm, frequency);
// Set the CMU CLK0
// FXCLK: used by TOM and CLK0: used by ATOM
}
// initialise TOM
IfxGtm_Tom_Pwm_Config tomConfig; \\configuration structure
IfxGtm_Tom_Pwm_Driver tomHandle; \\ handle
IfxGtm_Tom_Pwm_initConfig(&tomConfig, gtm);
tomConfig.period = 20;
tomConfig.dutyCycle = 10;
tomConfig.interrupt.isrPriority = TOM0_CH0_PRIO;
tomConfig.pin.outputPin = &IfxGtm_TOM0_0_TOUT106_P10_4_OUT;
IfxGtm_Tom_Pwm_init(&tomHandle, &tomConfig);

TOM will be now generating a PWM signal on the selected port pin while generating selected interrupt according to above configured period and duty cycle.