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.

MSP430FR6047: Difficulties in getting the Timer Captuer Counter value

Part Number: MSP430FR6047

Tool/software:

Dear Support Team,

I am encountering difficulties while developing firmware to retrieve the counter value from the Timer B0 Capture input (TB0.2, pin #33) on my MSP430FR6047 device.

Specifically, although the Timer B0 settings appear correct and the timer register TB0R increments as expected, both the CCI (Capture/Compare Input) signal indication and the capture compare register TB0CCR2 consistently read as zero. I suspect there might be an error in my configuration.

I am utilizing the TI DriverLib libraries (from: MSPDRIVERLIB Driver or library | TI.com).

Below is the relevant code segment for the Timer B0 capture mode initialization:

Timer_B_initCaptureModeParam Timer_B0_Param = {0};
    Timer_B_clearTimerInterrupt(TIMER_B0_BASE);
    
    Timer_B0_Param.captureInputSelect = TIMER_B_CAPTURE_INPUTSELECT_CCIxA;
    Timer_B0_Param.captureInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
    Timer_B0_Param.captureMode = TIMER_B_CAPTUREMODE_RISING_EDGE;
    Timer_B0_Param.captureOutputMode = TIMER_B_OUTPUTMODE_OUTBITVALUE;
    Timer_B0_Param.captureRegister = TIMER_B_CAPTURECOMPARE_REGISTER_2;
    Timer_B0_Param.synchronizeCaptureSource = TIMER_B_CAPTURE_ASYNCHRONOUS;
    TB0CTL = TB0CTL | CNTL_0 | TBSSEL_1 | ID__8; //Counter Length 0xFFFF, Clock Source ACKL (32kHz), Clock Divider = /8 -> Period 16s
    Timer_B_selectCounterLength(TIMER_B0_BASE, TIMER_B_COUNTER_16BIT);
    
    Timer_B_initCaptureMode(TIMER_B0_BASE, &Timer_B0_Param);

After applying these settings, I toggle the TB0.2 input (pin #33) and then attempt to read the captured value using:

Timer_B_getCaptureCompareCount(TIMER_B0_BASE, TIMER_B_CAPTURECOMPARE_REGISTER_2);

However, this function call consistently returns zero.

Hope it is clear. I am looking forward to hearing from you.

Kind regards,

Vladimir Zitoli

  • It appears that pin #33 (P3.2) can't be used for CCI[2A]. This is a bit unusual since it is TB0.2 (as output), but datasheet (SLASEB7D) Tables 9-17 and 9-29 seem to agree on this. You'll probably have to use P8.0 instead.

    You'll also need to:
    1) Configure the pin with something like:
    > GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P8, GPIO_PIN0, GPIO_SECONDARY_MODULE_FUNCTION ); // PSEL=10 from DS Table 9-39
    2) Start the timer (counter):
    > Timer_B_startCounter(TIMER_B0_BASE,TIMER_B_CONTINUOUS_MODE );

    [Edit: Fixed Table reference. Twice.]

  • Dear Bruce,

    thank you for your precious suggestion!

    Your reply was helpful to solve the issue. My misunderstanding started from datasheet's table 7-2, in which it is shown that pin #33 is the CCI2A input.

    Kind regards,

    Vladimir Zitoli

  • Hmm. I see what you mean about Table 7-2. Now I'm not sure who's right. 

    How did you end up fixing it? Either of the other things I mentioned would have produced the symptom you described .

  • I followed all of your suggestions and now it works. So I guess the Table 7-2 is incorrect.

    Thank you once again for the support.

    Kind regards,

**Attention** This is a public forum