5 Replies Latest reply on Oct 15, 2018 12:47 AM by user_56870023

    Missing binary data in UART receive interrupt

    user_56870023

      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;

      }

        • 1. Re: Missing binary data in UART receive interrupt
          user_1377889

          Try to change

          if ( UART_ReadRxStatus() == UART_RX_STS_FIFO_NOTEMPTY ){

          to

          if ( UART_ReadRxStatus() & UART_RX_STS_FIFO_NOTEMPTY ){

           

          Bob

          • 2. Re: Missing binary data in UART receive interrupt
            user_56870023

            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.

            • 3. Re: Missing binary data in UART receive interrupt
              ddka

              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

               

              • 4. Re: Missing binary data in UART receive interrupt
                user_1377889

                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

                • 5. Re: Missing binary data in UART receive interrupt
                  user_56870023

                  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.