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.

timer load value

Expert 1255 points
Other Parts Discussed in Thread: TM4C129XNCZAD

hi

I am using TM4C129XNCZAD on DK-TM4C129X

g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN |SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480),80000000);

SysCtlMOSCConfigSet(SYSCTL_MOSC_HIGHFREQ);

SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
IntMasterEnable();
TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);
TimerLoadSet(TIMER2_BASE, TIMER_A, 8*g_ui32SysClock); 
IntEnable(INT_TIMER2A);
TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);

TimerEnable(TIMER2_BASE, TIMER_A);

////////////////////////////TASK PARAMETERS IN TI RTOS/////////////////////////////

Task_Params_init(&taskParams);
taskParams.arg0 = 500; //task sleep time in # ticks
taskParams.priority = 1;
taskParams.stackSize = TASKSTACKSIZE;
taskParams.stack = &task1Stack;
Task_construct(&task1Struct, (Task_FuncPtr)hai, &taskParams, NULL);

I am not able to set the timer for 1 sec and task delay for half a second (there seems to be no sync)

Could you tell me what is the correct value to be loaded to the timer?

Thanks
av

  • Hello av,

    The timer load value that you are using will time out after approximately 8 seconds, but looks like you want it to expire after 1 second.

    Also can you explain what you mean by "there seems to be no sync"?

    Thanks,
    Sai
  • Hi Sai

    What i have figured out by running the program for different values is :

    1.5*g_ui32SysClock =1000*(tick period)  //correct me if I am wrong

    Now i am able to trigger the timer interrupt exactly when a task has reached completion and not in between. This was initially creating the sync problem.

    0.5sec||0.5 sec||>>

    TaskA ||TaskA ||Timer interrupt@ 1sec

    To get the interrupt exactly at 1 second, what is value i should load to the timer?

    Thanks a lot

    av

  • To interrupt after about 1 sec, you should load "g_ui32SysClock" value (assuming it is the clock frequency). You can check this by creating a new project (without RTOS) and toggling a GPIO on every interrupt. Then hook-up a scope to the GPIO and check if the toggle occurs approximately about 1 second or not.

    Is there a reason why you want to sync the timer with the task completion? If you want a synchronization event, using RTOS resources (like Semaphores) is the best way.

    Thanks,
    Sai