Rich (BB code):
#include "msp430x24x.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P3SEL |= 0x0C0; // P3.6,7 = USCI_A1 TXD/RXD
UCA1CTL1 |= UCSSEL_2; // SMCLK
UCA1BR0 = 8; // 1MHz 115200
UCA1BR1 = 0; // 1MHz 115200
UCA1MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5 ucbrs0
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UC1IE |= UCA1RXIE; // Enable USCI_A1 RX interrupt
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCIAB0RX_ISR(void){
while (!(UC1IFG & UCA1TXIFG)); // USCI_A1 TX buffer ready?
UCA1TXBUF = UCA1RXBUF; // TX -> RXed character
}
Thanks in advance
Last edited by a moderator: