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

This interface allows to generate simple PWM signal on a ATOM 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 ATOM0_CH0_PRIO 20

Interrupts

define Interrupts if needed

IFX_INTERRUPT(ATOM0Ch0_ISR, 0, ATOM0_CH0_PRIO)
{}

Initialization

// install interrupt handlers
IfxCpu_Irq_installInterruptHandler (ATOM0Ch0_ISR, ATOM0_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 ATOM
IfxGtm_Atom_Pwm_Config atomConfig; \\configuration structure
IfxGtm_Atom_Pwm_Driver atomHandle; \\ handle
IfxGtm_Atom_Pwm_initConfig(&atomConfig, gtm);
atomConfig.tomChannel = IfxGtm_Tom_Ch_0;
atomConfig.period = 20;
atomConfig.dutyCycle = 10;
atomConfig.interrupt.ccu0Enabled = TRUE;
atomConfig.interrupt.isrPriority = ATOM0_CH0_PRIO;
IfxGtm_Atom_Pwm_init(&atomHandle, &atomConfig);

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