This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Wrong Charecter received through UART

Hi,

I am trying to communicate to my pc(hyper terminal)from Msp430f6779, In the board the RS 485 driver connected to UCA3 (P41 & P42).  In transmit buffer, I am getting wrong data on the board, While SENDING '1', I AM GETTING as 'BD', 2 as BB, 3 as 'BB'....7 as 'B7' and so on...

Can u please identify the issue in my code.  

Thanks for any help and suggestions...

void SetHighClk (void)
{
uint8_t pmm_status;


SFRIFG1 &= ~OFIFG ; // Clear fault flags
pmm_status = STATUS_FAIL;
while (pmm_status == STATUS_FAIL)
{
pmm_status = PMM_setVCore(PMM_BASE, PMM_CORE_LEVEL_3); // Set Vcore level 3 to meet high speed clock
}
UCSCTL1 = 0x0060; // 10.7`39.0MHz, Modulation Enable
UCSCTL2 = 0x116F; // 32kHz * 2 * (367+1) = 24MHz
UCSCTL3 = 0x0000; // XT1CLK the FLL reference clock, 1/1 division
UCSCTL4 = 0x0043; // ACLK Source XT1CLK, SMCLK DCOCLKDIV = 12.058624MHz, MCLK DCOCLK = 24.117248MHz
UCSCTL5 = 0x0000; // ACLK divider for external pin: 1/1 divider, ACLK divider: 1/1, SMCLK Divider: 1/1, MCLK divider: 1/1
UCSCTL6 = 0x01C0; // Do not use XT2, XT1 maximum drive capability, Low-frequency mode, XT1 not bypass, SMCLK on, XT1 on
UCSCTL7 &= ~(XT2OFFG | XT1LFOFFG | DCOFFG); // Clear XT2,XT1,DCO fault flags
UCSCTL8 = 0x070F; // Enable MODSC, effective SMCLK, valid MCLK, ACLK effective
}

void main(void)
{

unsigned char dummy_read;

WDTCTL = WDTPW | WDTHOLD; // Stop WDT
P4SEL0 |= P4SEL0_INIT; // Set P4.1, P4.2 to non-IO
P4DIR |= P4DIR_INIT; // Enable UCA3RXD, UCA3TXD
// P3SEL0 |= P3SEL0_INIT; // Set P3.0, P3.1 , P3.4, P3.5, P3.6, P3.7 to non-IO
// P3DIR |= P3DIR_INIT; // Enable UCA0RXD, UCA0TXD, UCA1RXD, UCA1TXD, UCA2RXD, UCA2TXD,
P4OUT &= ~BIT0; // the direction of RS 485 driver is controled by this port(P4.0) , This is set in low to enable reception
//P4OUT &= ~BIT0;


SetHighClk ();


// Disalbe UCA0 [USART0 bit 0 = H]
UCA3CTL1 |= UCSWRST;

// UCA0 Control 0 register setting
// (b7)Parity Enable (HIGH)
// (b6)Parity Selection Even (HIGH)
// (b5)MSB Selection LSB (LOW)
// (b4)Data bit 8bit (LOW)
// (b3)Stop bit selection 1 (LOW)
// (b2) Communication mode UART (LOW)
// (b1)Communication mode UART (LOW)
// (b0)UCSYNC LOW fix
UCA3CTL0 &= 0X00;//(0x80 | 0x40);

// UCA0 Control 1 register setting
// (b7)Clock Source Selection SMCLK (HIGH)
// (b6)Clock Source Selection SMCLK (LOW)
// (b5)Receive interrupt enable flag with errors Permit (HIGH)
// (b4)Receive interrupt enable flag break Permit (HIGH)
// (b3~1) LOW fix
// (b0) Disable UCA0 (LOW)
UCA3CTL1 = (UCSSEL1 | UCRXEIE | UCBRKIE| UCSWRST);

// Baudrate is 38400 = 12058624 / 314 (00013Ah)
UCA3BR0 = 0x3A;
UCA3BR1 = 0x01;
UCA3MCTLW = 0x00;

// Enable UCA0 [USART0 bit 0 = H]
UCA3CTL1 &= ~UCSWRST;

// Disable the transmit interrupt(Clear b1 of IE2)
UCA3IE &= ~UCTXIE;

// Dummy read to clear data remained in RXBUF
dummy_read = UCA3RXBUF;

// To clear the interrupt source flag register b0 of IFG2 reception
UCA3IFG &= ~UCRXIFG;

// To allow reception interrupt (Set b0 of IE2)
UCA3IE |= UCRXIE;
__enable_interrupt();
while(1)
{
c++;
c--;
}
// while ((UCA3IFG & UCRXIFG) == 0);
// c++; // to check th number of charectors recieved // breakpoint here



}


#pragma vector=USCI_A3_VECTOR
__interrupt void USCI_A3_ISR(void)
{
c++; // to check th number of charectors recieved /// But code execution control is not coming to this point, Value is always shown as 0
switch (__even_in_range(UCA3IV, 8)) // break point here
{
case USCI_NONE: break; // No interrupt
case USCI_UART_UCRXIFG: // RXIFG
while (!(UCA3IFG & UCTXIFG)) ; // USCI_A3 TX buffer ready?
UCA3TXBUF = UCA3RXBUF; // TX -> RXed character
break;
case USCI_UART_UCTXIFG: break; // TXIFG
case USCI_UART_UCSTTIFG: break; // TTIFG
case USCI_UART_UCTXCPTIFG: break; // TXCPTIFG
default: break;
}
}

**Attention** This is a public forum