This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280049C: CPU timer 1 configuration

Part Number: TMS320F280049C

I configured my F280049C CPU timer 1 to generate an interrupt of 500us (0.5 ms) but I am not sure if my configuratio is correct.  My configuation is below.

/**< configure system to run at 100MHz */
/**< PLLSYSCLK = 10MHz (SYSCTL_OSCSRC_OSC2) * 19 (IMULT) + 0.25 (FMULT) / 2 (PLLCLK_BY_2)*/

bool return_value = SysCtl_setClock(SYSCTL_OSCSRC_OSC2|SYSCTL_IMULT(0x13)
|SYSCTL_FMULT_1_4|SYSCTL_SYSDIV(0x2)
|SYSCTL_PLL_ENABLE);

Interrupt_register(INT_TIMER1, &timer::ISRTimer1);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TIMER1);

uint32_t temp = (uint32_t)(100000000 / 1000000 * 2000);
CPUTimer_setPeriod (CPUTIMER1_BASE, temp);
CPUTimer_setPreScaler (CPUTIMER1_BASE, 0);

CPUTimer_stopTimer(CPUTIMER1_BASE);
CPUTimer_reloadTimerCounter(CPUTIMER1_BASE);
CPUTimer_setEmulationMode(CPUTIMER1_BASE, CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT);
CPUTimer_clearOverflowFlag(CPUTIMER1_BASE);

/**< enable interrupt of the timer */
CPUTimer_enableInterrupt(CPUTIMER1_BASE);

/**< enable cpu interrupt number 13 for the timer 1 interrupt */
Interrupt_enable(INT_TIMER1);

/**< start timer */
CPUTimer_startTimer(CPUTIMER1_BASE);

I am using the lunch pad

From the debug window.  It seems the timer is slower than the desired time.   It is slow by a factor of 3.  Is it because it is in debug mode?

What can the problem be.

Thanks.

  • Hi,

    Your temp2 value does not seem to be correct. If you want the timer to run for 500us (0.5ms), then total period counts will be (500us/SYSCLK_PERIOD). In your case PLL is running at 96.5MHz, so the period will be 103.89ns.

    Based on which your temp2=4812

    Best Regards,

    Nirav