Tool/software: Code Composer Studio
Hi,
I am trying to create an easy program which sends 3 byte ('A', 'B' and 'C') every second. But the problem is that I just can obtain de first byte ('A'), the othe two do not appear. How can I solve this?
This is my code:
#include <msp430.h>
unsigned char data [3]={'A','B','C'};
void uartSend (unsigned char *pucData, unsigned char ucLength)
{
while(ucLength !=0)
{
// Wait for TX buffer to be ready for new data
while(!(UCA1IFG & UCTXIFG));
// Push data to TX buffer
UCA0TXBUF = *pucData;
// Update variables
ucLength--;
pucData++;
}
// Wait until the last byte is completely sent
while(UCA0STAT & UCBUSY);
}
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CCR0 = 32768-1;
TA1CTL = TASSEL_1 + MC_1 + TACLR; // ACLK, upmode, clear TAR
//Configuración UART
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 6; // 1MHz 9600 (see User's Guide)
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS_0 + UCBRF_13 + UCOS16; // Modln UCBRSx=0, UCBRFx=0,
// over sampling
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, enable interrupts
__no_operation(); // For debugger
}
// Timer A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER1_A0_VECTOR))) TIMER1_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
while (!(UCA0IFG&UCTXIFG)); // USCI_A0 TX buffer ready?
uartSend(data,3);
}
In the picture the data received through UART is shown.
Thanks in advance,
Regards