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.

LAUNCHXL-F2800137: CPU timer

Part Number: LAUNCHXL-F2800137
Other Parts Discussed in Thread: SYSCONFIG

prescaler =0

period=1000

above settings for cpu timer with interrupt enabled, once the counter reaches 0 it generates an interrupt, in interrupt handler made one gpio toggle, measured the time taken for 1000 counts it is 8.35us, calculated the time for 1 count it is 8.3ns

same settings this time period changed to 100, time taken for 100 counts is 1.33us now 1 count time is 13.3ns.

question is why base time is changing without change in settings? how to make base time constant?

  • Hello Manoj,

    Can you confirm that you only changed the PRDH:PRD register? The divide-down (TDDRH:TDDR) and prescaler (PSCH:PSC), and the SYSCLK should be unchanged. Also, check the compiled code in Disassembly to see if there has been anything changed about your interrupt, the timer itself should not change the time base unless you modify the TDDR or PSC registers.

    Best regards,

    Omer Amir

  • I double-checked the timing 13.3 ns you got, which looks to be a frequency of 75 MHz. It seems likely that some clock or timer divider is being used to get this value.

  • hi omer,

    i changed only period value and kept prescaler to 0 

  • Hello Manoj,

    Can you share the code you use to configure the timer and any other functions you use to configure the system clock? Your timer is reaching exactly 75 MHz, which makes it seem like an unintentional configuration through software rather than a hardware problem.

    Best regards,

    Omer Amir

  • CPUTimer_setEmulationMode(myCPUTIMER0_BASE, CPUTIMER_EMULATIONMODE_RUNFREE);
    CPUTimer_setPreScaler(myCPUTIMER0_BASE, 0U);
    CPUTimer_setPeriod(myCPUTIMER0_BASE, 10000U);
    CPUTimer_enableInterrupt(myCPUTIMER0_BASE);
    CPUTimer_stopTimer(myCPUTIMER0_BASE);

    CPUTimer_reloadTimerCounter(myCPUTIMER0_BASE);

    in sysconfig enabled cputimer, prescaler=0, changing period.

  • Hello Manoj,

    I tested this on my side with the following SysConfig and main.c setup:

    #include "driverlib.h"
    #include "device.h"
    #include "board.h"
    
    __interrupt void INT_myCPUTIMER0_ISR(void);
    
    void main(void)
    {
        Device_init();
        Interrupt_initModule();
        Interrupt_initVectorTable();
    
        EINT;
        ERTM;
        Board_init();
    
        CPUTimer_startTimer(myCPUTIMER0_BASE);
    
        while(1);
    }
    
    __interrupt void INT_myCPUTIMER0_ISR(void)
    {
        //GPIO_writePin(myGPIO0, 1);
        GPIO_togglePin(myGPIO0);
        CPUTimer_reloadTimerCounter(myCPUTIMER0_BASE);
        CPUTimer_startTimer(myCPUTIMER0_BASE);
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
        //GPIO_writePin(myGPIO0, 0);
    }

    I confirmed that using 1000 for the timer period produces a toggle time of about 8.5 us which, accounting for the ISR time and counts, produces the 8.3 ns clock time. I also confirmed with the 10,000 period time you used and got a toggle time of 85 us, which also produces the 8.3 ns clock time from before.

    I'm not sure what configurations you have in your project, but I recommend starting from a known working example and then only modifying the timer period. I used the F280013x timer example and just added in the CPU timer configurations you described and it works consistently.

    Best regards,

    Omer Amir