Elderflower14
Junior Member level 3
Hello,
I am working on MSP430F5438A and have done a simple UART program to echo back the transmitted character to the receiver buffer. The code worked fine. ButI had connected the UART to a bluetooth chip. I am able to transmit characters to the UART unable to receive any. So I took a step backwards, put an extra UART in MSP430 as it has 4 pairs of UART lines. Tried the simple UART code for loop back but it is not working now. I am highly concerned and any help will be highly appreciated. I am pasting the code below
#include "msp430x54x.h"
char buf[10];
int i=0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 0x20; //
UCA0BR1 = 0x00; //
//Not required right now.
//UCA0MCTL |= UCBRS_6+UCBRF_0; // Modulation UCBRSx=6, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A1 RX interrupt
P1DIR |= BIT0;
UCA0TXBUF=0x61;
while(!(UCA0IFG&UCTXIFG));
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled
__no_operation(); // For debugger
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
buf= UCA0RXBUF;
if(buf==0x61)
{
P1OUT ^= BIT0;
__delay_cycles(100000);
}
}
Kind Regards
Elderflower
I am working on MSP430F5438A and have done a simple UART program to echo back the transmitted character to the receiver buffer. The code worked fine. ButI had connected the UART to a bluetooth chip. I am able to transmit characters to the UART unable to receive any. So I took a step backwards, put an extra UART in MSP430 as it has 4 pairs of UART lines. Tried the simple UART code for loop back but it is not working now. I am highly concerned and any help will be highly appreciated. I am pasting the code below
#include "msp430x54x.h"
char buf[10];
int i=0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
UCA0CTL1 |= UCSSEL_1; // CLK = ACLK
UCA0BR0 = 0x20; //
UCA0BR1 = 0x00; //
//Not required right now.
//UCA0MCTL |= UCBRS_6+UCBRF_0; // Modulation UCBRSx=6, UCBRFx=0
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCRXIE; // Enable USCI_A1 RX interrupt
P1DIR |= BIT0;
UCA0TXBUF=0x61;
while(!(UCA0IFG&UCTXIFG));
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled
__no_operation(); // For debugger
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
buf= UCA0RXBUF;
if(buf==0x61)
{
P1OUT ^= BIT0;
__delay_cycles(100000);
}
}
Kind Regards
Elderflower