diff options
Diffstat (limited to 'msp430/main.c')
-rw-r--r-- | msp430/main.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/msp430/main.c b/msp430/main.c index 1e691d3..fd0489f 100644 --- a/msp430/main.c +++ b/msp430/main.c @@ -7,14 +7,14 @@ int main() WDTCTL = WDTPW | WDTHOLD; DCOCTL = 0; - BCSCTL1 = CALBC1_1MHZ; - DCOCTL = CALDCO_1MHZ; + BCSCTL1 = CALBC1_8MHZ; + DCOCTL = CALDCO_8MHZ; 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 + UCA0BR0 = 208; // 8MHz 38400 + UCA0BR1 = 0; UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1 UCA0CTL1 &= ~UCSWRST; @@ -35,16 +35,22 @@ int main() void foci_putchar(int ch) { - while (!(IFG2 & UCA0TXIFG)); + do asm("nop"); + while ((IFG2 & UCA0TXIFG) == 0 || (UCA0STAT & UCBUSY) == UCBUSY); UCA0TXBUF = ch; + while ((UCA0STAT & UCBUSY) == UCBUSY); } int foci_getchar(void) { int ch; - while (!(IFG2 & UCA0RXIFG)); + do asm("nop"); + while ((IFG2 & UCA0RXIFG) == 0 || (UCA0STAT & UCBUSY) == UCBUSY); ch = UCA0RXBUF; + do asm("nop"); + while ((UCA0STAT & UCBUSY) == UCBUSY); + foci_putchar(ch); return ch; } |