Missing binary data in UART receive interrupt

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
tayoc_301426
Level 1
Level 1

A binary data reception interrupt program is being created using CY8CKIT - 059.

The communication conditions are 19,200 bps DataBit = 8 Parity = non stop = 1 Rx buffersizu = 100 and actual reception is about 30 characters.

The interrupt module was connected to the rx_interrupu terminal of the UART.

I created the code as follows, but sometimes the data dropout occurs.

I would appreciate it if you could give me advice on what is the cause and how I can solve it.

Below is the receive interrupt part

if ( UART_ReadRxStatus() == UART_RX_STS_FIFO_NOTEMPTY ){

bufsize = UART_GetRxBufferSize();

        for(i=0;i<bufsize;i++)

        {

        data_cnt++;

                rev_data[data_cnt]=UART_GetByte();

        } 

            if (data_cnt==22 )whm_rev_end=1;

}

0 Likes
1 Solution

I would suggest to use instead of

if ( UART_ReadRxStatus() == UART_RX_STS_FIFO_NOTEMPTY ){

rather

while ( UART_ReadRxStatus() & UART_RX_STS_FIFO_NOTEMPTY ){

Bob

View solution in original post

0 Likes
5 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Try to change

if ( UART_ReadRxStatus() == UART_RX_STS_FIFO_NOTEMPTY ){

to

if ( UART_ReadRxStatus() & UART_RX_STS_FIFO_NOTEMPTY ){

Bob

0 Likes

thank you for your comment.

However, the phenomenon of missing data and garbled characters was not improved.

We use the communication monitor to confirm that the data at the input stage is normal.

Therefore, I believe that the cause is the program of the receiving part.

Although data is acquired continuously (300 ms interval), multiple interrupts are not performed, so it can not be thought that other processing is affected.

0 Likes

Can you share the log of actual data being sent and data being received?

Also, did you try other baud rates to check if the situation improved?

You bufferSize may not be being read accurately due to some reason. Please just use the below function and test if it works. Let me know your observations.

if ( UART_ReadRxStatus() == UART_RX_STS_FIFO_NOTEMPTY ){

             rev_data[data_cnt] = UART_GetByte();

            if (data_cnt==22 ) whm_rev_end=1;

            data_cnt++;

}

Regards,

Dheeraj

0 Likes

I would suggest to use instead of

if ( UART_ReadRxStatus() == UART_RX_STS_FIFO_NOTEMPTY ){

rather

while ( UART_ReadRxStatus() & UART_RX_STS_FIFO_NOTEMPTY ){

Bob

0 Likes
tayoc_301426
Level 1
Level 1

I received it normally. The cause was two.

First

UART_ReadRxStatus () == UART_RX_STS_FIFO_NOTEMPTY

'==' changed to '&'

next

In order to switch bit length or signal inversion, multiplexers etc. are arranged from the input pin to the UART module, but at that time the Sync mode of the input pin was changed from Double-Sync to Transparent.

With these, normal reception has become possible.

Since the number of characters to receive is immutable length, I will try to change the code with reference to Bob's comment.

Thank you very much.

0 Likes