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.

TM4C123GH6PM: Timer in Synchronize Mode

Part Number: TM4C123GH6PM

Hi,

I want to synchronize timer0,timer1 and timer2 GPTM available on tm4c123gh6pm Following is my code. I try to read the current value of timer by setting a breakpoint in while(1) but I found that the counters are not synchronized. Is my code not proper? Did i miss something?

int main(void) {
uint32_t a,b,c;
SysCtlClockSet(SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN|SYSCTL_USE_PLL|SYSCTL_SYSDIV_5);

SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);

TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);
TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);

TimerLoadSet(TIMER0_BASE,TIMER_A,SysCtlClockGet()-1);
TimerLoadSet(TIMER1_BASE,TIMER_A,SysCtlClockGet()-1);
TimerLoadSet(TIMER2_BASE,TIMER_A,SysCtlClockGet()-1);

TimerSynchronize(TIMER0_BASE,TIMER_0A_SYNC|TIMER_1A_SYNC|TIMER_2A_SYNC);


TimerEnable(TIMER0_BASE, TIMER_A);
SysCtlDelay(500);
TimerEnable(TIMER1_BASE, TIMER_A);
SysCtlDelay(500);
TimerEnable(TIMER2_BASE, TIMER_A);
SysCtlDelay(500);

while(1)
{
a=TimerValueGet(TIMER0_BASE,TIMER_A);
b=TimerValueGet(TIMER1_BASE,TIMER_A);
c=TimerValueGet(TIMER2_BASE,TIMER_A);

}
}

  • Hello Asif,

    Please see GPTM#01 Errata, I think that is what you are running into: www.ti.com/.../spmz849f.pdf

    Workaround is included with Errata description.

  • I have read GPTM#01 Errata, Implemented the given workaround but failed to observe the expected timer behaviour in synchronize mode.Following is my code:
    int main(void) {
    uint32_t a,b,c;
    SysCtlClockSet(SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN|SYSCTL_USE_PLL|SYSCTL_SYSDIV_5);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);

    TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);
    TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
    TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);

    TimerLoadSet(TIMER0_BASE,TIMER_A,SysCtlClockGet()-1);
    TimerLoadSet(TIMER1_BASE,TIMER_A,SysCtlClockGet()-1);
    TimerLoadSet(TIMER2_BASE,TIMER_A,SysCtlClockGet()-1);




    TimerEnable(TIMER0_BASE, TIMER_A);
    SysCtlDelay(500);
    TimerEnable(TIMER1_BASE, TIMER_A);
    SysCtlDelay(500);
    TimerEnable(TIMER2_BASE, TIMER_A);
    SysCtlDelay(500);
    TimerSynchronize(TIMER0_BASE,TIMER_0A_SYNC|TIMER_1A_SYNC|TIMER_2A_SYNC);
    TimerSynchronize(TIMER0_BASE,0);
    while(1)
    {
    a=TimerValueGet(TIMER0_BASE,TIMER_A);
    b=TimerValueGet(TIMER1_BASE,TIMER_A);
    c=TimerValueGet(TIMER2_BASE,TIMER_A);

    }
    }
  • Part Number: TM4C123GH6PM

    Hello cb1_mobile,

    I followed your workaround to synchronize the timers but failed. Following is the code.

    #include<stdint.h>
    #include<stdbool.h>
    #include"driverlib/sysctl.h"
    #include"driverlib/timer.h"
    #include"inc/hw_memmap.h"
    int main(void) {
    uint32_t a,b,c;
    SysCtlClockSet(SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN|SYSCTL_USE_PLL|SYSCTL_SYSDIV_5);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);

    TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);
    TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC);
    TimerConfigure(TIMER2_BASE, TIMER_CFG_PERIODIC);

    TimerLoadSet(TIMER0_BASE,TIMER_A,SysCtlClockGet()-1);
    TimerLoadSet(TIMER1_BASE,TIMER_A,SysCtlClockGet()-1);
    TimerLoadSet(TIMER2_BASE,TIMER_A,SysCtlClockGet()-1);
    TimerSynchronize(TIMER0_BASE,TIMER_0A_SYNC|TIMER_1A_SYNC|TIMER_2A_SYNC);


    TimerEnable(TIMER0_BASE, TIMER_A);
    SysCtlDelay(500);
    TimerEnable(TIMER1_BASE, TIMER_A);
    SysCtlDelay(500);
    TimerEnable(TIMER2_BASE, TIMER_A);
    SysCtlDelay(500);

    while(1)
    {
    SysCtlDelay(333333);
    TimerSynchronize(TIMER0_BASE,0);
    TimerSynchronize(TIMER0_BASE,TIMER_0A_SYNC|TIMER_1A_SYNC|TIMER_2A_SYNC);
    a=TimerValueGet(TIMER0_BASE,TIMER_A);
    b=TimerValueGet(TIMER1_BASE,TIMER_A);
    c=TimerValueGet(TIMER2_BASE,TIMER_A);

    }
    }

  • Hello Asif,

    I merged your new thread with this one as it is the same topic and we shouldn't have two identical threads running.

    For those who read this post, the thread referenced where cb1_mobile contributed is: e2e.ti.com/.../288250

    Regarding the issue, I am going to run your code and see what is missing on the configuration shortly.
  • Hello Asif,

    I have replicated the issue and am still debugging what is going on. While I am still working it currently, time is running short for the day so it's likely I will need to pick this back up on Monday. Just wanted to let you know this is open and ongoing for me.
  • Hello Asif,

    I am able to see the Timers synchronized correctly using this code:

    int main(void) {
    
    	uint32_t a,b,c;
    
    	SysCtlClockSet(SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN|SYSCTL_USE_PLL|SYSCTL_SYSDIV_5);
    
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
    
    	TimerConfigure(TIMER0_BASE,TIMER_CFG_PERIODIC);
    	TimerConfigure(TIMER1_BASE,TIMER_CFG_PERIODIC);
    	TimerConfigure(TIMER2_BASE,TIMER_CFG_PERIODIC);
    
    	TimerLoadSet(TIMER0_BASE,TIMER_A,SysCtlClockGet()-1);
    	TimerLoadSet(TIMER1_BASE,TIMER_A,SysCtlClockGet()-1);
    	TimerLoadSet(TIMER2_BASE,TIMER_A,SysCtlClockGet()-1);
    
    	TimerEnable(TIMER0_BASE, TIMER_A);
    	SysCtlDelay(500);
    	TimerEnable(TIMER1_BASE, TIMER_A);
    	SysCtlDelay(500);
    	TimerEnable(TIMER2_BASE, TIMER_A);
    	SysCtlDelay(500);
    
    	TimerSynchronize(TIMER0_BASE,TIMER_0A_SYNC|TIMER_1A_SYNC|TIMER_2A_SYNC);
    	TimerSynchronize(TIMER0_BASE,0);
    
    	TimerControlStall(TIMER0_BASE, TIMER_A, true); //Assist in debug by stalling timer at breakpoints
    	TimerControlStall(TIMER1_BASE, TIMER_A, true); //Assist in debug by stalling timer at breakpoints
    	TimerControlStall(TIMER2_BASE, TIMER_A, true); //Assist in debug by stalling timer at breakpoints
    
    	while(1)
    	{
    		SysCtlDelay(333333);
    
    		a=TimerValueGet(TIMER0_BASE,TIMER_A);
    		b=TimerValueGet(TIMER1_BASE,TIMER_A);
    		c=TimerValueGet(TIMER2_BASE,TIMER_A);
    	}
    }

    The TimerControlStall API calls are needed to be able to see the Synchronization in debug mode.

  • Thank you so much Ralph.