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.

cc3200 timer reload value is not setting in capture mode

Hi,

I am trying capture signal duration on gpio pin using cp module

So here is my init code for timer

void CCPEnable(void){
           MAP_PinConfigSet(PIN_05,PIN_TYPE_STD_PU,PIN_STRENGTH_6MA);  // Enable pull up
           MAP_TimerIntRegister(TIMERA2_BASE,TIMER_A,TimerIntHandler); // Register timer interrupt hander
           MAP_TimerPrescaleSet(TIMERA2_BASE,TIMER_A,0xff);       // Setting Prescaler to 255
           MAP_TimerConfigure(TIMERA2_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP));    // Configure the timer in edge count mode
           MAP_TimerControlEvent(TIMERA2_BASE,TIMER_A,TIMER_EVENT_BOTH_EDGES); // Set the detection edge
           MAP_TimerLoadSet(TIMERA2_BASE,TIMER_A,0x0);  // Set the reload value
           TimerValueSet(TIMERA2_BASE,TIMER_A,0x0);
           MAP_TimerIntEnable(TIMERA2_BASE,TIMER_CAPA_EVENT);        // Enable capture event interrupt
           MAP_TimerEnable(TIMERA2_BASE,TIMER_A);                 // Enable Timer
}

AND interrupt handler for this is here

static void TimerIntHandler()
{
    capturedValues[CCPindex] = MAP_TimerValueGet(TIMERA2_BASE,TIMER_A);
    CCPindex++;
}

here are some samples stored in capturedValues

16605223 16642853 32442 71683

1)Timer is running in 24 bit mode(0x000000-0xFFFFFF) HOW can i change it to 32 bit????

2)When timer overflows i am getting wrong values

means my signal is 425us which gave me two capture samples as 16642853 32442 which equals to (0xFFFFFF-16642853 + 32442)/80 = 2085

This behavior is happening only at overflow condition.

Except at overflow all the values are accurate.

WHY is this issue occurring???

  • Hi,
    So this is what i found
    timer runs up count from 0(0x000000) to 16777215(0xFFFFFF) a 24 bit number.
    So when rollover occurs (the transition between 16777215 to 0 ) some issue is occurring.
    I did experiment to find out this issue and i got this so far

    I am sending 1024us (1millisensond) HIGH AND LOW pulses continuously and printed MAP_TimerValueGet(TIMERA2_BASE,TIMER_A);
    values. below are some samples at over flow
    sample1)16477777 16559751 16641719 12011 93980 175954 257923 339581 421549
    sample2)16438722 16520691 16602665 16684633 54926 136895 218553 300522 382496
    sample3)16387071 16469039 16551012 16632981 3273 85241 166899 248868 330841 412809

    So difference between every sample must be 1024us but at over flow it is 819us more.
    1)I am not sure that is it overflow early? or timer is starting at 65583 instead of 0

    I hope it will help to find the issue.
    Thanks
  • Suresh,

    Please check w/ below configuration and let me know if it works.

    void CCPEnable(void){
               MAP_PinConfigSet(PIN_05,PIN_TYPE_STD_PU,PIN_STRENGTH_6MA);  // Enable pull up
               MAP_TimerIntRegister(TIMERA2_BASE,TIMER_A,TimerIntHandler); // Register timer interrupt hander
               MAP_TimerPrescaleSet(TIMERA2_BASE,TIMER_A,0xff);       // Setting Prescaler to 255
               MAP_TimerConfigure(TIMERA2_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME_UP));    // Configure the timer in edge count mode
               MAP_TimerControlEvent(TIMERA2_BASE,TIMER_A,TIMER_EVENT_BOTH_EDGES); // Set the detection edge
               //MAP_TimerLoadSet(TIMERA2_BASE,TIMER_A,0x0);  // Set the reload value
               //TimerValueSet(TIMERA2_BASE,TIMER_A,0x0);
               MAP_TimerLoadSet(TIMERA2_BASE,TIMER_A,0xFFFF);  // Set the reload value
               MAP_TimerIntEnable(TIMERA2_BASE,TIMER_CAPA_EVENT);        // Enable capture event interrupt
               MAP_TimerEnable(TIMERA2_BASE,TIMER_A);                 // Enable Timer
    }
    
    static void TimerIntHandler()
    {
               MAP_TimerIntClear(TIMERA2_BASE,TIMER_CAPA_EVENT);
               capturedValues[CCPindex] = MAP_TimerValueGet(TIMERA2_BASE,TIMER_A);
               CCPindex++;
    }

    And also, refer section:9.3.2.3 of CC3200-TRM for more details.

    -/Praneet

  • I'm closing this thread - For any additional information, please start a new thread w/ references to the current one for us to track it better.

    -/Praneet