Other Parts Discussed in Thread: MSP430F5528
Hi!
I'm using MSP-TS430PZ100E (MSP450FR6047) and SN5176B differential transceiver to communicate with PC through RS485/USB converter.
I've never used SN5176B before. Or more accurately, I have no experience of using UART for RS485 interface. The only successful experience of using UART was communication with TTL with TDS7200EVEM (MSP430F5528).
I had to use UCA2 (P5.0 - TXD, P5.1 - RXD, P5.2 - RE/DE) because UCA0 and UCA1 are either already being used for JTAG or too far from the breadboard. The schematic is as below;
I used TI's sample code of "msp430fr60x7_euscia0_uart_01.c" after modifying them as below;
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop Watchdog
// Configure GPIO
P5SEL0 &= ~(BIT0 | BIT1);
P5SEL1 |= BIT0 | BIT1; // USCI_A0 UART operation
P5DIR |= BIT2; // P5.2 -> DE, ~RE, output
P5OUT &= ~ BIT2; //
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
// Startup clock system with max DCO setting ~8MHz
CSCTL0_H = CSKEY_H; // Unlock CS registers
CSCTL1 = DCOFSEL_3 | DCORSEL; // Set DCO to 8MHz
CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
CSCTL0_H = 0; // Lock CS registers
// Configure USCI_A0 for UART mode
UCA2CTLW0 = UCSWRST; // Put eUSCI in reset
UCA2CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK
// Baud Rate calculation
// 8000000/(16*9600) = 52.083
// Fractional portion = 0.083
// User's Guide Table 24-4: UCBRSx = 0x04
// UCBRFx = int ( (52.083-52)*16) = 1
UCA2BRW = 52; // 8000000/16/9600
UCA2MCTLW |= UCOS16 | UCBRF_1 | 0x4900;
UCA2CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA2IE |= UCRXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM3_bits + GIE); // Enter LPM3, interrupts enabled
__no_operation(); // For debugger
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=EUSCI_A2_VECTOR
__interrupt void USCI_A2_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(EUSCI_A2_VECTOR))) USCI_A2_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA2IV, USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
while(!(UCA2IFG&UCTXIFG));
UCA2TXBUF = UCA2RXBUF;
__no_operation();
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
default: break;
}
}
As below, I checked whether the TXD port is giving output by continuously sending a character using oscilloscope and confirmed that it's giving output.
while(1)
{
// if( i>0)
{
i--;
P1OUT ^= (BIT0|BIT1); // Toggle LED
__delay_cycles(100000);
__delay_cycles(100000);
__delay_cycles(100000);
__delay_cycles(100000);
__delay_cycles(100000);
__delay_cycles(100000);
__delay_cycles(100000);
__delay_cycles(100000);
__delay_cycles(100000);
}
if(bBUT_MENU)
{
Show("Button Menu pressed.");
}
else
{
Show("MaxiFlo Heat Meter");
}
UCA2TXBUF = 'A';
UCA2TXBUF = 'b';
// __bis_SR_register(LPM4_bits | GIE); // Enter LPM4 w/interrupt
__no_operation(); // For debugger
}
Please help me!!!

