Tool/software: Code Composer Studio
As we are using MSP430F2618 controller for our application , we have are both UART as for modbus protocol .
what we observed is on sending/query the data to UART every reguler interval say at 500msec once in while we are missing the data reception
Example : we are sending 8 byte query we are receiving only 7 bytes.
code snippet:
static volatile unsigned char ChARxBuffer[SIZE_ChARxBuffer];
static volatile unsigned char ChATempRxBuffer[SIZE_ChARxBuffer];
static volatile unsigned char *ChARxBufRdPtr = ChARxBuffer, *ChARxBufWrPtr = ChARxBuffer; //Buffer and pointers for received bytes
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCIAB0RX_VECTOR))) USCI0RX_ISR (void)
#else
#error Compiler not supported!
#endif
{
*ChARxBufWrPtr++ = UCA0RXBUF; //Put received character in the buffer
if (ChARxBufWrPtr > &ChARxBuffer[SIZE_ChARxBuffer - 1]) //Check if end of buffer
ChARxBufWrPtr = ChARxBuffer; //Wrap pointer to beginning
MBChAData.MbBtRcdSize++;
if(timer_run==0)
{
ui810msCounter = CHA_RX_TIMEOUT;
timer_run=1;
}
RestartMucTimer();
}
//here
//baudrate = 9600
//parity = even 1 stop bits
void vfnInit_SCI0(void)
{
UCA0CTL0 = ucarrParity[strPCProgammed.ucModbusParity];
UCA0CTL1 = 0X80;
UCA0BR0 = ucarrBRLow[strPCProgammed.ucModbusBaudRate];
UCA0BR1 = ucarrBRhigh[strPCProgammed.ucModbusBaudRate];
//UCA0MCTL = UCBRS2 + UCBRS0; // Modulation UCBRSx = 5
UCA0CTL1 &= ~UCSWRST;
UCA0STAT = 0x00;
ucPtrPCComm_Rx = (unsigned char *)&ucarrRxBuf[0];
MB_CHA_DIR_RX_ENABLE();
PC_COMM_ENABLE_RX_INTR();
}