Hi
In the following program i am trying to initialize 2 UARTS at a time (MSP430F5438A). In which, the TX of one of the uart is transmitted to the RX of the other and vice versa.
But i am unable to get the intended output for the same. Can someone please suggest me what went wrong in the prog. The prog seems to work fine while just sending the bytes from one uart TX buffer to the corresponding RX buffer of the other UART and not when both the buffers are TXed and RXed simultaneously .
//****Program for echo back the RXed character from the TX buffer of the other UART (working fine)****//
#include "msp430x54xA.h"
void sys_uart1_int(void);
void sys_uart2_int(void);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
sys_uart1_int ();
sys_uart2_int ();
__bis_SR_register(LPM0_bits + GIE);
__no_operation();
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(__even_in_range(UCA1IV,4))
{
case 0:break;
case 2:
while (!(UCA1IFG&UCTXIFG));
UCA0TXBUF = UCA1RXBUF;
break;
case 4:break;
default: break;
}
}
void sys_uart2_int(void)
{
P5SEL = 0xC0;
UCA1CTL1 |= UCSWRST;
UCA1CTL1 |= UCSSEL_2;
UCA1BR0 = 9;
UCA1BR1 = 0;
UCA1MCTL |= UCBRS_1 + UCBRF_0;
UCA1CTL1 &= ~UCSWRST;
UCA1IE |= UCRXIE;
}
void sys_uart1_int (void)
{
P3SEL = 0x30;
UCA0CTL1 |= UCSWRST;
UCA0CTL1 |= UCSSEL_2;
UCA0BR0 = 9;
UCA0BR1 = 0;
UCA0MCTL |= UCBRS_1 + UCBRF_0;
UCA0CTL1 &= ~UCSWRST;
UCA0IE |= UCRXIE;
}
//***Program for echo back the RXed character from the TX buffer of the other UART and vice versa (not working as intended)***//
#include "msp430x54xA.h"
void sys_uart1_int(void);
void sys_uart2_int(void);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
sys_uart1_int ();
sys_uart2_int ();
__bis_SR_register(LPM0_bits + GIE);
__no_operation();
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
switch(__even_in_range(UCA1IV,4))
{
case 0:break;
case 2:
while (!(UCA1IFG&UCTXIFG));
UCA0TXBUF = UCA1RXBUF;
break;
case 4:break;
default: break;
}
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,4))
{
case 0:break;
case 2:
while (!(UCA0IFG&UCTXIFG));
UCA1TXBUF = UCA0RXBUF;
break;
case 4:break;
default: break;
}
}
//***********************//
//**UART INITIALISATION**//
void sys_uart1_int (void)
{
P3SEL = 0x30;
UCA0CTL1 |= UCSWRST;
UCA0CTL1 |= UCSSEL_2;
UCA0BR0 = 9;
UCA0BR1 = 0;
UCA0MCTL |= UCBRS_1 + UCBRF_0;
UCA0CTL1 &= ~UCSWRST;
UCA0IE |= UCRXIE;
}
void sys_uart2_int(void)
{
P5SEL = 0xC0;
UCA1CTL1 |= UCSWRST;
UCA1CTL1 |= UCSSEL_2;
UCA1BR0 = 9;
UCA1BR1 = 0;
UCA1MCTL |= UCBRS_1 + UCBRF_0;
UCA1CTL1 &= ~UCSWRST;
UCA1IE |= UCRXIE;
}
Regards
Binoy