1 Reply Latest reply on Sep 22, 2020 9:18 AM by GaneshD_41

    UART (SCB) receive issues - missing bytes

    user_2457466

      Hi,

       

      we have two PCBs utilizing a PSOC 4 BLE (CY8C4248LQI-BL553). These a able to communication via a UART interface, RX + TX.

      For this purpose we use a SCB component. This is in unconfigured state, because depending on the hardware variant, this can be an I2C interface instead.

       

      I have a scope on the RX and TX lines and I have been able to observe that even though the bytes are present on the data lines, the PSOC does not seem to receive them. Some times 1 or 2 bytes are missing in the receive buffer and I cant explain why this is.

       

      RxSize and TxSize is 193.

       

      In UART mode, the interface is initialized like this:

       

      // Disable Component before re-configuration

          InterComm_Stop();

       

          // UART clock setup - clock to SCB component

          InterCommClock_Start();

          //InterCommClock_SetFractionalDividerRegister( 25, 1 );    // 48 MHz / (26 1/32) ~= 1,8432 MHz -> 115200 baud rate

          InterCommClock_SetFractionalDividerRegister( 52, 0 );    // 48 MHz / 52 ~= 923,077kHz

       

          SetInterCommIoToUart();

       

          InterComm_UART_INIT_STRUCT configUart;

          memset( &configUart, 0, sizeof(InterComm_UART_INIT_STRUCT) );

          configUart.mode = InterComm_UART_MODE_STD;

          configUart.direction = InterComm_UART_TX_RX;

          configUart.dataBits = 8;

          configUart.parity = InterComm_UART_PARITY_NONE;

          configUart.stopBits = InterComm_UART_STOP_BITS_1;

       

          s_pucUartRxBuffer = new uint8_t[ RxSize + 1 ];    // The buffer size must equal (rxBufferSize + 1) in bytes

       

          configUart.rxBuffer = ( uint8* ) s_pucUartRxBuffer;

          configUart.rxBufferSize = RxSize;

       

          s_pucUartTxBuffer = new uint8_t[ TxSize ];

          configUart.txBuffer = ( uint8* ) s_pucUartTxBuffer;

          configUart.txBufferSize = TxSize;

       

          configUart.enableMedianFilter = 1; // Test

          // 1,8432 MHz / 16 = 115200 baud rate

          //configUart.oversample = 16;//InterComm_UART_IRDA_LP_OVS16;

       

          // 923,077kHz / 8 = 115200 baud rate

          configUart.oversample = 8;//InterComm_UART_IRDA_LP_OVS16;

       

          configUart.enableInterrupt = 1; // Enable interrupt

          configUart.rxInterruptMask = InterComm_INTR_RX_NOT_EMPTY;

          configUart.txInterruptMask = 0;

       

          InterComm_SetCustomInterruptHandler( InterComm_ISR );

       

          InterComm_UartInit( &configUart );

          InterComm_Start();

       

          s_ucInterface = ( uint8_t ) HAL_INTERCOMM_UART;

          s_ucInitialized = 1;

       

       

      Reception is handled by a timer. each 4 ms we perform the following:

       

      while( InterComm_SpiUartGetRxBufferSize() > 0 )

      {

        ch = ( uint8_t ) InterComm_SpiUartReadRxData();

       

        .... // handling received bytes ....

      }

        • 1. Re: UART (SCB) receive issues - missing bytes
          GaneshD_41

          Hi,

           

          I guess there may be a mismatch with baudrate or timing. Can you please attach both the PSoC 4 BLE projects? It will be easy for us to test and find the issue if you can attach the projects.

           

          Are you using any PSoC 4 code example as reference for developing your application? If not, please go through the UART code examples in PSoC Cretor.

           

          Are you using UDB based UARTs in your application? In either of the case, you can directly set the Baud rate in the UART component itself. You dont have to configure it using a clock component.

           

          Thanks

          Ganesh