Tool/software:
Hello,
I have three questions about timer and PWM for TMS320F2800157.
1.
This is the code used to configure a 1 ms timer:
void myCPUTIMER0_init(){
CPUTimer_setEmulationMode(myCPUTIMER0_BASE, CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
CPUTimer_setPreScaler(myCPUTIMER0_BASE, 119U);
CPUTimer_setPeriod(myCPUTIMER0_BASE, 1000U);
CPUTimer_enableInterrupt(myCPUTIMER0_BASE);
CPUTimer_stopTimer(myCPUTIMER0_BASE);
CPUTimer_reloadTimerCounter(myCPUTIMER0_BASE);
CPUTimer_startTimer(myCPUTIMER0_BASE);
}
The controlCARD uses a 20 MHz crystal oscillator as the PLL source.
#define DEVICE_OSCSRC_FREQ 20000000U
// Clock configuration:
// PLLSYSCLK = 20 MHz (XTAL_OSC) * 48 (IMULT) / (2 (REFDIV) * 4 (ODIV) * 1 (SYSDIV))
#define DEVICE_SETCLOCK_CFG (SYSCTL_OSCSRC_XTAL | SYSCTL_IMULT(48) | \
SYSCTL_REFDIV(2) | SYSCTL_ODIV(4) | \
SYSCTL_SYSDIV(1) | SYSCTL_PLL_ENABLE | \
SYSCTL_DCC_BASE_0)
// Resulting SYSCLK = 120 MHz based on DEVICE_SETCLOCK_CFG
#define DEVICE_SYSCLK_FREQ ((DEVICE_OSCSRC_FREQ * 48) / (2 * 4 * 1))
In this configuration, the prescaler is set to 119, which divides the 120 MHz clock down to 1 MHz. However, the documentation does not clearly state how the CPUTimer_setPeriod() function handles the period value. To achieve a 1 ms timer interval, should we use:
CPUTimer_setPeriod(myCPUTIMER0_BASE, 1000U);
or should it be:
CPUTimer_setPeriod(myCPUTIMER0_BASE, 999U);
(in other words, should the period value be 1000 or 1000 - 1)?
We’d appreciate clarification on this.
2.
Also for the PWM, we want to drive LEDs for adjust the brightness.
I referenced to the epwm_ex11_configure_signal.c example.
EPWM_setCounterCompareValue(myEPWM0_BASE, EPWM_COUNTER_COMPARE_A, (val));
//
// Enable interrupts required for this example
//
Interrupt_enable(INT_EPWM1);
The interrupt is enabled, but there is no handling function. Is the interrupt necessary for this function to work? It is enabled in the example.
3.
When we generate code for the PWM, the SYNC_init() function is also generated:
void SYNC_init(){
SysCtl_setSyncOutputConfig(SYSCTL_SYNC_OUT_SRC_EPWM1SYNCOUT);
//
// SOCA
//
SysCtl_enableExtADCSOCSource(0);
//
// SOCB
//
SysCtl_enableExtADCSOCSource(0);
}
However, our application does not require SYNC.
To disable SYNC, should I follow the steps shown in the figures below?


Best regards,
Egemen