rendered paste body#include <msp430g2553.h>const char keyMap[4][3] = {{'1','2','3'},{'4','5','6'},{'7','8','9'},{'*','0','#'},};const char rowPins[4] = {BIT4, BIT5, BIT6, BIT7};const char colPins[3] = {BIT0, BIT1, BIT2};void main(void){ //Kill WDT and setup clocks WDTCTL = WDTPW + WDTHOLD; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; //Port Setup P1DIR = BIT4 + BIT5 + BIT6 + BIT7; // Enable P1 outputs used for row scanning P1OUT &= ~(BIT4 + BIT5 + BIT6 + BIT7); // Set outputs to LOW P2REN |= BIT0 + BIT1 + BIT2; // Enable weak pull up resistors on the P2 inputs used for column scanning. //Setup USCI P1SEL = BIT1 + BIT2; P1SEL2 = BIT1 + BIT2; UCA0CTL1 |= UCSSEL_2; UCA0BR0 = 104; UCA0BR1 = 0; UCA0MCTL = UCBRS0; UCA0CTL1 &= ~UCSWRST; //Timer interrupt used to read the keypad to see if a key is being pressed CCTL0 = CCIE; CCR0 = 30000; TACTL = TASSEL_2 + MC_1; _BIS_SR(LPM0_bits + GIE); // LPM0 + interrupt}// TimerA0 ISR#pragma vector=TIMER0_A0_VECTOR__interrupt void Timer_A (void){ char i; char j; for(i=0; i < 4; i++){ P1OUT &= ~rowPins[i]; //row LOW for(j=0; j < 3; j++){ if(!(P2IN & colPins[j])){ UCA0TXBUF = keyMap[i][j]; while(!(P2IN & colPins[j])); //blocking while a key is held down } } P1OUT |= rowPins[i]; //row HIGH }}