Tool/software: Linux
Greetings,
I was trying to get to know UART with MSP430g2553 with the following code:
#include <msp430g2553.h>
int main (void) {
WDTCTL = WDTPW + WDTHOLD;
DCOCTL = 0;
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
P1DIR |= BIT6 + BIT0;
P1SEL = BIT1 | BIT2;
P1SEL2 = BIT1 | BIT2;
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // brattVisto na tabela do userguide pra 1mhz 9600 baud
UCA0BR1 = 0; // Visto tambem no user guide pra 1mhz 9600 baud
UCA0MCTL = UCBRS0; // modulation UCBRSx = 1
// Take UCA from RESET
UCA0CTL1 &= ~UCSWRST;
// Enable USCI A0 RX Interrupt
IE2 |= UCA0RXIE;
__bis_SR_register(LPM0_bits + GIE); // enabling all interrupts (including UART's)
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void) {
while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX; RXed character
P1OUT ^= (BIT0 + BIT6);
}
So, i go to the terminal and do the following command:
$ echo 'a' > /dev/ttyACM0
When i do the command, it sends the character, supposedly it should turn on both of the leds but it turns out to turn on and off almost instantly.
If i do the same command but with two characters, such:
$ echo 'aa' > /dev/ttyACM0
The result is brighter LEDs and they stay in HIGH state (leds on), if i do the command again the leds are turned off.
So, i would like to know why do i get a different result by sending an odd or even number? How can i fix that? i would like to send just one character and get the same result as sending two characters.