Part Number: MSP430F5438A
Hi,
I am using MSP430F5438A microcontroller for my application. I am using UCA0xxx module for UART. So I wanted to transmit 505 hex values from my GUI to my microcontroller.
But the thing is I am only able to receive first 60 bytes. after that my code stuck at while(!(UCA0IFG & UCRXIFG)); loop. So I am not able to receive complete bytes.
I am using UART in interrupt mode so every time I send values it will generate an interrupt. Actually this whole bytes I am sending as a packet. So my packet format would be like below.
0x23(Header) 0x01 0xF9(Length - 2 bytes) 0xC4(Command ID) (... 505 hex values ...) 0x61(CRC checksum).
So when I transmit these values I am only able to receive first 60 bytes and code hangs at while(!(UCA0IFG & UCRXIFG));
SINT32 uart_getchar(void)
{
SINT8 chr;
while(!(UCA0IFG & UCRXIFG)); <<<<< Code hangs ere after receiving first 60 bytes
chr = UCA0RXBUF;
return chr;
}
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
{
UINT8 u8ReadVal = 0;
UINT32 u32LoopVar=0, u32Index;
UINT16 u16PacketLen;
switch(__even_in_range(UCA0IV,4))
{
case 0:break;
case 2:
__disable_interrupt();
do
{
u8ReadVal = UCA0RXBUF; //uart_getchar();
}while( PKT_START != u8ReadVal);
/* Store Header */
gau8Read[u32LoopVar++] = u8ReadVal;
/* Read Length of the frame from Uart */
u8ReadVal = uart_getchar();
/* Store Length */
gau8Read[u32LoopVar++] = u8ReadVal;
u16PacketLen = (0xFF & u8ReadVal);
u8ReadVal = uart_getchar();
gau8Read[u32LoopVar++] = u8ReadVal;
u16PacketLen |= ((0xFF & u8ReadVal) << 8u);
/* store rest */
for(u32Index = u32LoopVar; u32Index < u16PacketLen; u32Index++)
{
u8ReadVal = uart_getchar();
/* Store Length */
gau8Read[u32Index] = u8ReadVal;
}
u8Received = 1;
break;
case 4:break;
default: break;
}
}
This code works fine for other packets I send.