Hi,
I am using LPC54608J512BD208. I have a custom desktop application sends me data through USART. Some packets sends to MCU are greater than 16 datas and I can see just first 16 datas, others are empty. I used logic analyzer and I see that PC application is sending all bytes. The issue is on MCU side. I can't configure PC app to send me less than 16 datas so I have to do something with LPC546. What should I do ? I checked FIFOSTAT, it is 1000f2. So that means RX FIFO is full. How can I emtpy it and then receive other datas ?
void InitializeUart(void)
{
usart_config_t config;
USART_GetDefaultConfig(&config);
config.baudRate_Bps = 9600;
config.enableRx = true;
config.enableTx = true;
IOCON->PIO[3][16] = 0x0301;
IOCON->PIO[3][17] = 0x0301;
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM8);
USART_Init(USART8, &config, CLOCK_GetFreq(kCLOCK_Flexcomm8));
}
This is my reading data routine:
void USART_Read(USART_Type *base, uint16_t *data, size_t length)
{
for (; length > 0; length--)
{
*data = base->FIFORD;
data++;
}
}
I have tried something like this but nothing changed:
void USART_ReadBlocking(USART_Type *base, uint16_t *data, size_t length)
{
int i = 0;
for (i = 0; i < 16; i++)
{
*data = base->FIFORD;
data++;
}
base->FIFOCFG |= USART_FIFOCFG_EMPTYRX_MASK;
for (i = 0; i < 16; i++)
{
*data = base->FIFORD;
data++;
}
}
Hello,
I highly recommend you to refer to our SDK examples. In our USART examples there is implementation of clearing FIFO in case RX FIFO error occurred in USART_ReadBlocking.
/* check rxFIFO statusFlag */
if ((base->FIFOSTAT & USART_FIFOSTAT_RXERR_MASK) != 0U)
{
base->FIFOCFG |= USART_FIFOCFG_EMPTYRX_MASK;
base->FIFOSTAT |= USART_FIFOSTAT_RXERR_MASK;
status = kStatus_USART_RxError;
break;
}
Best regards,
Felipe