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.
Hello all,
I am tring to set up my MSP to measure frequency of a signal @ TB0.4 (pin 52) of the MSP430FR5994.
my code is as follows..
Inititailase timer TB0.4
void init_TB0_4() { P1DIR &= ~BIT7; // Set P1.7 as an input P1SEL0 |= BIT7; // Select Timer_B function for P1.7 P1SEL1 &= ~BIT7; TB0CTL = TBSSEL__SMCLK | MC__CONTINOUS | TBIE | ID_1 | TBCLR; // Set Timer B0 clock source to system clock enable timer B interrupt TB0CCTL4 = CAP | CM_1 | CCIS_1 | SCS_1; // Configure Timer B0.4 CAPture mode. Rising edge. CCIxB. Synchronous capture }
Interrupt Handler
#pragma vector = TIMER0_B1_VECTOR __interrupt void Timer0_B1_ISR(void) { switch(__even_in_range(TB0IV,TB0IV_TB0IFG))// { case TB0IV_TB0CCR4: //FCount[Fpoint++] = TA1CCR1; if (TB0CCR4 < LastVal) { Overflow += 0x10000; } FCount[Fpoint++] = TB0CCR4 + Overflow; LastVal = TB0CCR4; if (Fpoint >=64) { TB0CCTL4 &= ~CCIE; Freq = (FCount[63] - FCount[0])>>6; splitUint16(Freq, &f_msb, &f_lsb); // Split 16bit Freq into two 8bit numbers UART_TXBuffer[0] = f_msb; // Element 0 of UART_TXBuffer array hold frequency count msb UART_TXBuffer[1] = f_lsb; // Element 1 of UART_TXBuffer array hold frequency count lsb TXbyte = 0; // Initialise TXbyte TX_Data_Len = 2; // Number of bytes to be sent UCA1TXBUF = UART_TXBuffer[TXbyte++]; // Transmit the first byte from UART_TXBuffer array Fpoint = 0; LastVal = 0; //for(clrFCount=0; clrFCount<32; clrFCount++) //{ //FCount[clrFCount] = 0; //} } break; case TB0IV_TBIFG: break; default: break; } }
i had the code working on my Dev board using Timer A1.1 (pin3) as the input and all worked fine.
Now i am running on my own board using TB0.4 it does not work, i dont even hit a break point in the case TB0IV_TB0CCR4: when the interrut gets enabled (TB0CCTL4 |= CCIE) which is set elewhere in my code.
i'm a completly new to C and MSP coding so appologies if this a basic mistake but I cannot see wherre i have gone wrong.
Thanks,
Iain
I don't see anything obviously wrong here. I'd start with the basics:
1) Is the ISR ever called? (I.e. breakpoint on the switch() rather than the case:)
2) Are you using Low Power Mode (LPM)? With LPM level >= LPM2, SMCLK is turned off.
3) Are you fairly certain the signal is reaching the pin?
Hello,
Turns out it was a case of operator error. My signal was getting to the pin but as the sine was was centred aroud ground the MSP didn't like it (i hadnt noticed my fuction generator settings had been changed). Thanks for promping me to check the input signal i'd probably still be staring at my code if not!
Careful, if this is a 50 ohm generator, you can damage the ESD diodes with too much negative voltage.
How do you know? You can damage the ESD diode without affecting the input pin operation.
**Attention** This is a public forum