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.

MSP430G2553: TimerA used to measure tachometer pulse clock wont start & input held low

Part Number: MSP430G2553

Tool/software:

Hi: Thank you in advance for any help on this issue.

I am attempting to monitor the timing of pulses from a hall effect sensor connected to P2.5 of a MSP430G2553 chip on a launchpad.

As is, the timerA never starts and the TA1R register remains at zero. When I comment out the InitHallSensor() code, the timer counts up as expected.

Also, the hall sensor circuit gives correct pulsing when the pin 13 of the launchpad (P2.5) is disconnected but remains low when it is connected (as detected on scope).

I am trying to keep things simple and not using digital I/O of the port/pin. Do I have to use port interrupts (pin as digital I/O) or can I skip that and go directly to trigger the timer capture interrupt through CCI2B input as indicated on the MSP430G2553 datasheet?

Here is my circuit for the hall effect sensor (018 412).

Here is my code.

#include <intrinsics.h>
#include <msp430.h>
#include <stdio.h>
#include <stdint.h>

void InitPorts(void);
void InitHallSensor(void);

#define SENSOR_PIN BIT5   //attach hall sensor to P2_5 TA1.2

volatile unsigned int cntOvrFloTAR = 0;
volatile uint16_t currTimerCounts = 4;

int main(void)
{
	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
    //set up Basic Clock Module
    BCSCTL1 |= DIVA_3; //this write clears all other bits; divide ACLK/8
    BCSCTL3 |= XCAP_3; //sets internal capacitance for watch crystal

    InitPorts();
    InitHallSensor();
	
    //Set up Timer1A
    // capture on rising edge, CCI2B input, synchronous cap, capture mode, ints enabled
    TA1CCTL2 = CM_1 | CCIS_1 | CAP | CCIE | SCS;
    // Continuous, divide clock by 1, ACLK, clear, enable
    TA1CTL = MC_2 | ID_0 | TASSEL_1 | TACLR | TAIE;
    __enable_interrupt();

    for(;;){
        // wait
    }
}
#pragma vector = TIMER1_A1_VECTOR
__interrupt void TIMER1_A1_ISR (void){
    switch (__even_in_range(TA1IV, 10)){
    case 0:
        break;
    case TA1IV_TACCR2:
        TA1CCTL2 &= ~CCIE;    // disable further CCIE interrupts
        currTimerCounts = TA1CCR2;
        cntOvrFloTAR = 0; //reset TAR rollover counter
        TA1CCTL2 &= ~CCIFG; // clear the CCRO flag
        TA1CCTL2 |= CCIE; //enable interrupts
        break;
    case TA1IV_TAIFG:
        ++cntOvrFloTAR;
        break;
    default:
        for (;;){
            //Should not be possible
        }
    }
}
void InitPorts(void){
    P1OUT = 0;
    P1DIR = 0xFF;
    P2OUT = 0;
    P2DIR = 0xFF;
}
void InitHallSensor(void){
    P2DIR &= ~SENSOR_PIN; //Set pin as input
    P2SEL = SENSOR_PIN; //Set pin for Timer1_A CCI1A capture
}

**Attention** This is a public forum