USART interrupt on LPC55S69 Board not receiving more than 17 bytes

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

USART interrupt on LPC55S69 Board not receiving more than 17 bytes

541 次查看
sushmasan
Contributor II

Hello Team,

I tried different possibilities, but in the USART interrupt handler I am able to receive only receive only 17bytes.

This is my interrupt handler code, please let me know if I am missing anything,

#define BUFF_SIZE 256
uint8_t rx_buffer[BUFF_SIZE];

void Test_USART2_IRQHandler(void)
{
    uint8_t data;
    while ((0x1F<<USART_FIFOSTAT_RXLVL_SHIFT) & (USART_IF2->FIFOSTAT))
    {
       data = USART_ReadByte(USART_IF2);
       if (((rxHeadIndex + 1) % BUFFER_SIZE) != rxTailIndex)
       {
           rxBuffer[rxHeadIndex] = data;
           rxHeadIndex++;
           rxHeadIndex %= BUFFER_SIZE;
       }
    }
    USART_DisableInterrupts( USART_IF2, kUSART_RxLevelInterruptEnable | kUSART_RxErrorInterruptEnable );

    SDK_ISR_EXIT_BARRIER;
}

// Processing the received data in another task, and enabling interrupts after copying the complete data.

With this I am receiving this data,

Received -> 1
Received -> 2
Received -> 3
Received -> 4
Received -> 5
Received -> 6
Received -> 7
Received -> 8
Received -> 9
Received -> 10
Received -> 11
Received -> 12
Received -> 13
Received -> 14
Received -> 15
Received -> 16
Received -> 17

In the same interrupt handler code, If I include these lines, after USART_ReadByte,

 
// Check for the RX FIFO Overflow error and if exist, clear that error
if ((USART_IF2->FIFOSTAT & USART_FIFOSTAT_RXERR_MASK))
 {
    PRINTF("RX FIFO Overflow error, so clearing it\r\n");
    USART_IF2->FIFOSTAT |= USART_FIFOSTAT_RXERR_MASK;
 }

I am receiving this data,

Received -> 1
RX FIFO Overflow error, so clearing it
Received -> 2
Received -> 3
Received -> 4
Received -> 5
Received -> 6
Received -> 7
Received -> 8
Received -> 9
Received -> 10
Received -> 11
Received -> 12
Received -> 13
Received -> 14
Received -> 15
Received -> 16
Received -> 17

But the other device is sending 30bytes to LPC55S69.

Can you please let me know, where the other bytes lost and why those are not received fully?

 

Regards,

San

0 项奖励
回复
4 回复数

522 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @sushmasan,

Please take a look at our USART example codes from the LPCXpresso55s69 SDK as these example codes will prove useful for your issue. You can download the SDK on the following link: Select Board | MCUXpresso SDK Builder

BR,
Edwin.

0 项奖励
回复

520 次查看
sushmasan
Contributor II

Hi @EdwinHz ,

Thanks for your response.

I already tried example code between two USART and even tested loop back mode.

But in my application the data is sent by another device to LPC55S69.

I also saw an explanation in this thread, but still I am seeing the issue.

https://community.nxp.com/t5/LPC-Microcontrollers/USART-interrupt-on-LPC55S69-Board/td-p/1848624

Regards,
San

0 项奖励
回复

470 次查看
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @sushmasan,

As you can see in section "34.6.10 FIFO Configuration register" of the "LPC55S6x/LPC55S2x/LPC552x User manual" (UM11126), the USART FIFO size is forcefully configured as 16 entries of 8 bits.

This is why you are only receiving 16 entries (1 through 17).

As mentioned on the following community post, you need to clear the FIFO in order to receive more than 16 bytes: Re: Receiving Moren Than 16 Data via USART - NXP Community.

BR,
Edwin.

0 项奖励
回复

457 次查看
sushmasan
Contributor II

Hi @EdwinHz ,

Thanks for your response.

I am not doing it correctly to clear the RX fifo overflow. Also I found another cause, as I am using a debug message inside the interrupt handler that is causing the issue.

Now everything is working fine.

Regards,
San

0 项奖励
回复