HelloI'm sure this is obvious, but I used the example code for hardware serial for the MSP430My problem is:The code never runs my while(1)The code returns "Hello World" when I send uThe code does not toggle the pin when I send cTips appreciated :D [code]#include "msp430g2553.h"#define BEEP_PIN BIT0const char string1[] = { "Hello World\r\n" };unsigned int charLoop;void main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop WDT BCSCTL1 = CALBC1_1MHZ; // Set DCO DCOCTL = CALDCO_1MHZ; P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 104; // 1MHz 9600 UCA0BR1 = 0; // 1MHz 9600 UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt //set outputs P1DIR |= BEEP_PIN; P1OUT = 0x00; //clear port 1 __bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled while (1) { P1OUT ^= BEEP_PIN; // Toggle LED on P1.0 __delay_cycles(1000000); // Wait ~100ms at default DCO of ~1MHz }}#pragma vector=USCIAB0TX_VECTOR__interrupt void USCI0TX_ISR(void){ UCA0TXBUF = string1[charLoop++]; // TX next character if (charLoop == sizeof string1 - 1) // TX over? IE2 &= ~UCA0TXIE; // Disable USCI_A0 TX interrupt}#pragma vector=USCIAB0RX_VECTOR__interrupt void USCI0RX_ISR(void){ if (UCA0RXBUF == 'u') // 'u' received? { charLoop = 0; IE2 |= UCA0TXIE; // Enable USCI_A0 TX interrupt UCA0TXBUF = string1[charLoop++]; } else if (UCA0RXBUF == 'c') { P1OUT &= BEEP_PIN; __delay_cycles(100000); P1OUT &= ~BEEP_PIN; }}[/code]
Ok,Solved my own problemin the example code__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabledputs the CPU to sleepchanging it to __bis_SR_register(GIE); worked