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.

TM4C129ENCPDT: Timer Configuration Done but T0CCP1 does capture the count

Part Number: TM4C129ENCPDT

Hello Team,

I'm using TM4C129ENCPDT controller. Configured the T0CCP0,T0CCP1, and T1CCP1 for frequency measurements.

I have configured the Timer0 for Split operation and the TimerA and B for capturing the pulses. I'm getting the right values for T0CCP0 and T1CCP1 but, there is no data available for T0CCP1.

Below is the code:

//Initalisation

void Init_Freq_Measure(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOL));
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD));
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER0));
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_TIMER1));

TimerLoadSet(TIMER0_BASE, TIMER_BOTH, 0xFFFF);
//TimerLoadSet(TIMER0_BASE, TIMER_B, 0xFFFF);
TimerLoadSet(TIMER1_BASE, TIMER_B, 0xFFFF);

GPIOPinTypeTimer(GPIO_PORTL_BASE,GPIO_PIN_7);
GPIOPinConfigure(GPIO_PL7_T1CCP1);
GPIOPinTypeTimer(GPIO_PORTD_BASE,GPIO_PIN_0);
GPIOPinConfigure(GPIO_PD0_T0CCP0);
GPIOPinTypeTimer(GPIO_PORTD_BASE,GPIO_PIN_1);
GPIOPinConfigure(GPIO_PD1_T0CCP1);

TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_CAP_COUNT_UP|TIMER_CFG_A_CAP_COUNT_UP);
TimerControlEvent(TIMER0_BASE, TIMER_BOTH, TIMER_EVENT_POS_EDGE);

TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_CAP_COUNT_UP);
TimerControlEvent(TIMER1_BASE, TIMER_B, TIMER_EVENT_POS_EDGE);

TimerEnable(TIMER0_BASE, TIMER_BOTH);
TimerEnable(TIMER1_BASE, TIMER_B);

}

//Timer 2 Interrupt for 1 sec.

void Timer2IntHandler (void)
{
TimerIntClear(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
start_r = end_r;
start_y = end_y;
start_b = end_b;
end_r = TimerValueGet(TIMER0_BASE, TIMER_A);
end_y = TimerValueGet(TIMER0_BASE, TIMER_B);
end_b = TimerValueGet(TIMER1_BASE, TIMER_B);
freq_r = CalculateFreq(start_r,end_r);
freq_y = CalculateFreq(start_y,end_y);
freq_b = CalculateFreq(start_b,end_b);

}

Thank you in advance.


Regards

Shijin

  • Hello All,

    Resolved this issue.

    The causing trouble was a mistake i did in the sequence.

    I have called "TimerLoadSet" before "TimerConfigure" due to which the Timer 0 was considered as Single Timer and the Timer B load value was not updated.

    Now with the right sequence this rectified.

    Thank you
    Regards
    Shijin.
  • Thank you for posting the solution you found. This might help someone else who runs into the same problem.
  • Such help would be better facilitated if poster's (original) code would reflect his FIX!       (FIX described as, "Having called "TimerConfigure" before "TimerLoadSet".)

    Review of poster's (earlier) code shows the "solution" to "not yet" have reached his "initial posting."     (reducing the correction's value - Devil "basks" in such detail...) 

    Functions in Green should be called prior to those in Red!     (as stated by thread's originator - this is simple copy/paste of poster's original code - simply "color highlighted" in the attempt to spare others from repeating poster's earlier mistake!))

    TimerLoadSet(TIMER0_BASE, TIMER_BOTH, 0xFFFF);        // Must occur after "TimerConfigure" function in Green (below)

    //TimerLoadSet(TIMER0_BASE, TIMER_B, 0xFFFF);

    TimerLoadSet(TIMER1_BASE, TIMER_B, 0xFFFF);             // Must occur after "TimerConfigure" function in Green (below)

    GPIOPinTypeTimer(GPIO_PORTL_BASE,GPIO_PIN_7);

    GPIOPinConfigure(GPIO_PL7_T1CCP1);

    GPIOPinTypeTimer(GPIO_PORTD_BASE,GPIO_PIN_0);

    GPIOPinConfigure(GPIO_PD0_T0CCP0);

    GPIOPinTypeTimer(GPIO_PORTD_BASE,GPIO_PIN_1);

    GPIOPinConfigure(GPIO_PD1_T0CCP1);

    TimerConfigure(TIMER0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_CAP_COUNT_UP|TIMER_CFG_A_CAP_COUNT_UP);     // Enter before "TimerLoadSet" in red (above)

    TimerControlEvent(TIMER0_BASE, TIMER_BOTH, TIMER_EVENT_POS_EDGE);

    TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_B_CAP_COUNT_UP);       // Enter before "TimerLoadSet" in red (above)