Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

MSP430F247 : TimerB in capture mode for 3 inputs

$
0
0

Hi,

I've a board with 3 signals connected on P4.1, P4.2 and P4.3.

I want to measure frequency of these signals, by configuring 3 intputs in compare mode, with interrupt on rising edge.

If I understand, there's only one interrupt (TimerB1_Vector)

My code doesn(t work, i never go in interrupt, signal is present and toggle (scope), but MSP430 doesn't see rising edge :

COuld you help me by reviewing following code? Is there an example somewhere with more than one signal used in capteur mode?

Thanks in advance

Init code :

P4DIR = 0x00;

P4SEL = 0x0E

TB0CCTL1 = CM_2 + CCIS_1 + CAP + CCIE;

TB0CCTL2 = CM_2 + CCIS_1 + CAP + CCIE;

TB0CCTL3 = CM_2 + CCIS_1 + CAP + CCIE;

Interrupt Code :

#pragma vector = TIMERB1_VECTOR
    __interrupt void Timer_B1 (void)
    {
        switch(TBIV)
         {
                  case  TBIV_NONE: break;              // Vector  0:  No interrupt
                  case  TBIV_TBCCR1:                   // Vector  2:  TBCCR1 CCIFG
                      // Rising Edge was captured
                      if (!Count1)
                      {
                          R1Edge1 = TB0CCR1;
                         Count1++;
                      }
                     else
                     {
                         R1Edge2 = TB0CCR1;
                         Count1=0x0;
                    }
                  break;
                  case  TBIV_TBCCR2:                   // Vector  3:  TBCCR2 CCIFG
                      // Rising Edge was captured
                      if (!Count2)
                      {
                          R2Edge1 = TB0CCR2;
                         Count2++;
                      }
                     else
                     {
                         R2Edge2 = TB0CCR1;
                         Count2=0x0;
                    }

                  default:     break;
              }
    }


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>