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.

Measuring Timer expiration time

Hi,

I'm using the am243x-EVM.

I setup a Timer for 31.25usec with "syscfg" 

Is it a valid setup ?

Inside the callback I'm toggling the LED26 and attach an oscilloscope on the LED26 to measure the period.

I'm getting a square wave that shows toggle every ~100msec instead of expected 32usec.

Is it a valid method of measuring ?

How can I setup the timer correctly and measure correctly ?

Thanks,

Eli

  • Hi Eli,

    You will need to start the timer after setup:

    I tested above setting with the following timer ISR in empty project. Let it run 10 secs and then check the gTimerCounter value. gTimerCounter*31.25/1000000 is around 10.

    uint32_t gTimerCounter = 0;
    void myTimerISR(void)
    {
       gTimerCounter++;
    }

    void empty_main(void *args)
    {
       /* Open drivers to open the UART driver for console */
       Drivers_open();
       Board_driversOpen();

       while (1)
       {

       }

       DebugP_log("All tests have passed!!\r\n");

       Board_driversClose();
       Drivers_close();
    }

    Best regards,

    Ming

  • Hi Ming,

    I'm starting the timer by   TimerP_start(gTimerBaseAddr[CONFIG_TIMER0]);

    then it gets into the callback I wrote.

    bool b_led_toggle=false;

    void TimerTick(void)
    {
     debug_led_on(b_led_toggle);
     b_led_toggle=!b_led_toggle;

    }

    The osciloscope shows toggling ~100msec. not 32usec

    If I do 

    uint32_t counter=0;

    void TimerTick(void)
    {
     counter++;

    }

    If I divide after 10 secs I get ~1000

    I suspect the timer is really working at 100msec 

    I've tried to use priority 0  - same timing !

    I'm using FreeRTOS in the background can it affect the timer ticks ?

    Please advice,

    Thanks,

    Best Regards,

    Eli

  • Hi Eli,

    According to your test result, 10 secs the counter is ~1000. The Tick Period is set to 10000us (10ms), but the default Tick Period for a new timer instance is 1000us (1ms). Something is wrong here.

    FreeRTOS only uses the TIMER8. It should not affect the DMTimer0.

    Which version of the MCU+ SDK are you using? I am using the AM243x MCU+ SDK 09.01.00.41

    Best regards,

    Ming

  • Hi Ming ,

    Now the timer runs ok - 31.25usec.

    I think maybe re-build helped , but I'm not sure what was the problem.

    Thanks,

    Best Regards,

    Eli