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.

MSP430F5529 Timer_A0 in Capture Mode - Monitoring the TA0.1

Other Parts Discussed in Thread: MSP430WARE

I know Capture Mode is not used very much, but I am trying to configure Timer0_A5.  I am also using the MSP430ware rather then the memory-mapped C macors.

I configure the Timer to run in UpMode:

    Timer_A_initUpModeParam inittaram = {0};
    inittaram.clockSource = TIMER_A_CLOCKSOURCE_ACLK;
    inittaram.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
    inittaram.timerPeriod = 0x08FF;
    inittaram.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_ENABLE;
    inittaram.captureCompareInterruptEnable_CCR0_CCIE = TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE;
    inittaram.timerClear = TIMER_A_DO_CLEAR;
    inittaram.startTimer = false;
    Timer_A_initUpMode(TIMER_A0_BASE, &inittaram);

This code works great.  I get and detect both interrupts for TAR=0 and for TAR=CCR0.  My problem comes when I try to use CCR1 to perform a capture:

   Timer_A_initCaptureModeParam inittaram = {
                                              .captureRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1,
                                              .captureMode     = TIMER_A_CAPTUREMODE_RISING_EDGE,
                                              .captureInputSelect = TIMER_A_CAPTURE_INPUTSELECT_GND,  // Switch to Vcc should cause interrupt
                                              .synchronizeCaptureSource = TIMER_A_CAPTURE_ASYNCHRONOUS,
                                              .captureInterruptEnable = TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE,
                                              .captureOutputMode = TIMER_A_OUTPUTMODE_TOGGLE,
                                             };
    
    Timer_A_initCaptureMode(TIMER_A0_BASE, &inittaram);

In my main loop, when I toggle TA0CCTL1 ^= CCIS_1; I get the Capture Interrupt.  However, the TA0.1 pin (P1.2), doesn't seem to toggle at the correct moment.

I think my understanding of the outputMode for a capture timer is unclear.  I expect the TA0.1 pin to toggle every time I toggle the CCIS_1 bit.

It may help if I show you my main loop:

while (1 /* data != 0x00 */)
    {    
        xferData(&data, 1);
        data--;
        __delay_cycles(100);
        /* This causes an edge on the input of CCR1 which is configured as a */
        /* Capture Timer.  This generates an INT. */
        if (data == 0x00)
        {
            TA0CCTL1 ^= CCIS_1;
        }
    }

The data that is being transferred is a single byte via SPI.  So I would expect to see my TA0.1 pin toggle at the same time my SPI data is 0x00.  It looks like it is toggling more with TAR=CCR0

Can someone explain how the TA0.1 signal works when configuring CCR1 isn Capture Mode?

Thanks,

Jim

  • Oh and BTW, I do have pin 1.2 configured at an output peripheral :)
  • Capture mode is indeed used less than compare, but what makes this case especially rare is the use of the output unit with capture mode.

    My interpretation of table 17.2.5.1 in the F5/6 Family User's Guide is that the output operations triggered by TAxCCRn (n!=0) might not occur in capture mode because TAxR never "counts to" the value in TAxCCRn.

    What happens if you use one of the output modes that additionally sets the output when TAxR counts to the value in TAxCCR0? I'd expect that part of the output unit to work correctly in this situation, so if it doesn't there may be something else wrong.

  • Section 17.1 defines "count":

    Count is used throughout this chapter. It means the counter must be in the process of counting for the action to take place. If a particular value is directly written to the counter, an associated action does not take place

    In Capture mode, the only usable output mode is "Output".

  • Thanks guys.  I knew my understanding of Capture mode was slightly skewed.  I read the "note" on the definition of count and guess it did not sink in.  I need to fully understand what TA0.1 (OUT1) is doing.  Since I have it set in TOGGLE mode,  and it is indeed "toggling".  Yet, Clemens Ladisch is correct , a value is getting written into CCR1.  However, count refers to TAR.  I will play with it a little more and see what is causing the TA0.1 line to toggle.

    Thanks for all your insight.

    Jim

**Attention** This is a public forum