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.

UART transmission

Other Parts Discussed in Thread: MSP430G2553

Need some help! Im supposed to transmit character strings from msp430g2553 to pc via comm operator pal. But the twist is to send only the character string when switch 1 of the msp is pressed. Ive already made an ISR but i dont think this is ok. Ive already run the program and its not working.

#include "msp430g2553.h"

//function prototypes
void printuart(char *str);

void main( void )
{
//Initialization

WDTCTL = WDTPW + WDTHOLD; // Stop WDT , not used

BCSCTL1 = CALBC1_1MHZ; // DCO 1 MHz
DCOCTL = CALDCO_1MHZ; // DCO at 1 MHz

P1SEL |= 0x06; // Set pin modes to USCI_A0
P1SEL2|= 0x06; // Set pin modes to USCI_A0
P1DIR |= BIT2; // Set 1.2 to output
UCA0CTL1 |= UCSSEL_2; // Use SMCLK (remember:this is sourced from DCO)
UCA0BR0 = 104; // 1 MHz -> 9600 N=Clock/Baud
UCA0BR1 = 0; // 1 MHz -> 9600
UCA0MCTL = UCBRS1; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI see User Guide
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt see User Guide

//Indicator Set Up and Interrupt

P1DIR|=BIT6;
P1REN=BIT3; //switch1
P1IE = BIT3;
P1IES |= BIT3;
P1IFG &= ~BIT3;

//Enable Interrupts
_BIS_SR(GIE);


//Repeats this section

while(1)
{
}
}

// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{

printuart("Charleston O. Melgar \n\n");
__delay_cycles(1000000);
P1IFG &= ~BIT3; // P1.3 IFG cleared

}

void printuart(char *str)
{
P1OUT |= BIT6; // green LED on

unsigned int i;
unsigned int size = strlen(str); //get length of string
for (i = 0; i < size; i++) {

while (!(IFG2 & UCA0TXIFG)); //Wait UART to finish before next send
UCA0TXBUF = str[i];
}

P1OUT &= ~BIT6; //green LED off
}

**Attention** This is a public forum