Hi all,
I have question regarding msp430 controller. I am working on msp430fr6922 controller. I am trying to communicate between MSP430 controller and Raspi using serial USB to TTL cable. I have attached code for your refernce. UART is working on ACLK which is 32.768 kHZ and baud rate set is 9600. In receive mode, sometimes data bytes are missing. What is the reason??
#include "common.h"
int RPI_UART(void)
{
// Configure USCI_A0 for UART mode
UCA0CTLW0 = UCSWRST; // Put eUSCI in reset
UCA0CTLW0 |= UCSSEL__ACLK; // CLK = SMCLK
// Baud Rate calculation
// 8000000/(16*9600) = 52.083
// Fractional portion = 0.083
// User's Guide Table 21-4: UCBRSx = 0x04
// UCBRFx = int ( (52.083-52)*16) = 1
UCA0BR0 = 3; // 9600 baud
UCA0MCTLW |= 0x5300; // 32768/9600 - INT(32768/9600)=0.41
// UCBRSx value = 0x53 (See UG)
UCA0BR1 = 0;
UCA0CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
while(!(UCA0IFG&UCTXIFG));
RXDATA[p++]=UCA0RXBUF;
if (RXDATA[0]==0x01)
{
if(p==3)
{
p=0;
giNewFrameFlag=1;
}
}
else
{
p=0;
}
break;
case USCI_UART_UCTXIFG: break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
}
}