Hello fellows,
I'm trying to communicate my launchpad with my serial port PC with HyperTerminal.
Here is what's happening:
Using the example code I can get communication when I select the following settings:
HYPERTERMINAL
@9600 8bits, non-parity, 1stpbit. Flow=none.
Success when set ACLK (UCA0CTL1 |= UCSSEL_1) and UCA0BR0 = 0x03.
But when I try with SMCLK (UCA0TL1 |= UCSSEL_2) and UCA0BR0 = 6 or 104 (as shown on pdf), I've got wrong characters at hyperterminal. Doesn't match with keyboard.
The point is: I NEED to use 38400bps. And with ACLK at 32k, the fastest BR is 9600. So using BR @38400, I've got the same wrong characters.
What is the problem, anybody?
Here is the code:
#include "msp430g2553.h"
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR = 0xFF; // All P1.x outputs
P1OUT = 0; // All P1.x reset
P2DIR = 0xFF; // All P2.x outputs
P2OUT = 0; // All P2.x reset
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2= BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P3DIR = 0xFF; // All P3.x outputs
P3OUT = 0; // All P3.x reset
UCA0CTL1 |= UCSSEL_2; // CLK = SMCLK
UCA0BR0 = 26; // 1MHz/38400
UCA0BR1 = 0x00; //
UCA0MCTL = UCBRS1 + UCBRS0; // Modulation UCBRSx = 3
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
}
Thanks everybody!
Any help can be helpful!
Regards