6 Replies Latest reply on Jul 28, 2020 3:05 AM by DheerajP_41

    wiced_hal_puart_read

    HaGo_4718696

      i need explanation and solution of below mentioned program

       

      /* Interrupt callback function for UART_RX */

      void spp_rx_data( void *data )

      {

           WICED_BT_TRACE("    ");

          unsigned int i;

          char ch;

          uint8_t  readbyte;

       

          /* Read one byte from the buffer and (unlike GPIO) reset the interrupt */

          wiced_hal_puart_read( &readbyte );

          rx_buffer[rx_count++] = readbyte;

       

         wiced_hal_puart_reset_puart_interrupt();

       

          if(wiced_hal_puart_rx_fifo_not_empty() == FALSE)

          {

              WICED_BT_TRACE("fifo false at:%s\n",&rx_buffer[0]);

              clear_rx_buffer();

          }

       

      }

       

      in above function wiced_hal_puart_rx_fifo_not_empty() is not returning expected value when commanting  WICED_BT_TRACE

       

      i am getting result like

      WICED_BT_TRACE("    ");  //not commanted

      Rx data :123456789

      fifo false at:1

      fifo false at:23456789

      here fifo empty at first byte.

       

      //WICED_BT_TRACE("    ");  //commanted

      Rx data :123456789

      fifo false at:123456789

      here fifo empty after reading all data

       

       

      regarding this anyone can help me.

        • 1. Re: wiced_hal_puart_read
          HaGo_4718696

          sorry above i mentioned wrong actually

           

          //WICED_BT_TRACE("    ");  //commanted

          Rx data :123456789

          fifo false at:1

          fifo false at:23456789

          here fifo empty at first byte.

           

          WICED_BT_TRACE("    ");  //not commanted

          Rx data :123456789

          fifo false at:123456789

          here fifo empty after reading all data

          • 2. Re: wiced_hal_puart_read
            DheerajP_41

            Hi,

             

            Since you are coding for PUART communication, I would prefer you to disable the debug traces (WICED_BT_TRACE), Or re-route the debug traces to HCI UART instead of PUART, using wiced_set_debug_uart(). Please check wiced_debug_uart_types_t in wiced_bt_trace.h.

            Because, debug traces on PUART can create some errors in the actual data that we want to send via PUART.

             

            Thanks,

            -Dheeraj

            1 of 1 people found this helpful
            • 3. Re: wiced_hal_puart_read
              HaGo_4718696

              hi dheeraj sir,

               

              thanks for your reply.

               

              actually why wiced_hal_puart_rx_fifo_not_empty not filling properly when i am commanting  WICED_BT_TRACE

               

              if i use WICED_BT_TRACE then wiced_hal_puart_rx_fifo_not_empty  is fillling properly.

              • 4. Re: wiced_hal_puart_read
                DheerajP_41

                Hi,

                 

                Could you please share your code with us where you have implemented the puart functionality. I will to go through the code and try to reproduce the issue.

                 

                Are you able to reproduce the issue after disabling all the debug traces in the app as I mentioned in my previous response?

                 

                Thanks,

                -Dheeraj

                • 5. Re: wiced_hal_puart_read
                  HaGo_4718696

                  APPLICATION_START()

                  {

                      wiced_result_t result;

                  #if defined WICED_BT_TRACE_ENABLE || defined HCI_TRACE_OVER_TRANSPORT

                      wiced_transport_init(&transport_cfg);

                      host_trans_pool = wiced_transport_create_buffer_pool(TRANS_UART_BUFFER_SIZE, TRANS_MAX_BUFFERS);

                      wiced_set_debug_uart( WICED_ROUTE_DEBUG_TO_PUART );

                      wiced_hal_puart_init( );

                      wiced_hal_puart_select_uart_pads( WICED_PUART_RXD, WICED_PUART_TXD, 0, 0);

                      wiced_hal_puart_flow_off( );

                      wiced_hal_puart_set_baudrate( 115200 );

                      wiced_hal_puart_enable_tx( );

                      wiced_hal_puart_enable_rx();

                    /* Enable receive and the interrupt */

                    wiced_hal_puart_register_interrupt( spp_rx_data );

                    wiced_hal_puart_enable_tx( );

                   

                  #endif

                    wiced_bt_stack_init(app_management_callback, &wiced_bt_cfg_settings, wiced_bt_cfg_buf_pools);

                  }

                   

                   

                  /* Interrupt callback function for UART */

                  void spp_rx_data( void *data )

                  {

                        WICED_BT_TRACE("               ");   // IF WE ENABLE THIS FIFO UPDATING PROPERLY

                      uint8_t  readbyte;

                   

                      /* Read one byte from the buffer and (unlike GPIO) reset the interrupt */

                      wiced_hal_puart_read( &readbyte );

                      rx_buffer[rx_count++] = readbyte;

                      wiced_hal_puart_reset_puart_interrupt();

                      if(puart_rxFifoNotEmpty() == FALSE ) //WAITING FOR  FIFO EMPTY

                      {

                            if(spp_handle != 0)

                                 wiced_bt_spp_send_session_data(spp_handle, rx_buffer, rx_count);

                          

                      }

                  }

                   

                   

                  Q:Are you able to reproduce the issue after disabling all the debug traces in the app as I mentioned in my previous response?

                  A:YES BUT NOT UPDATING FIFO

                   

                  THANKS,

                  HARI

                  • 6. Re: wiced_hal_puart_read
                    DheerajP_41

                    Hi,

                     

                    Unfortunately, I couldn't reproduce the issue using the above code snippet which you have provided. PUART is functioning properly.

                    Two point, I have observed is,

                    • You are calling wiced_hal_puart_enable_tx( ); two time in the PUART initialization part.
                    • We have to use wiced_hal_puart_rx_fifo_not_empty() instead of puart_rxFifoNotEmpty().

                     

                    May i know which IDE & SDK are you using? WICED Studio or Modustoolbox ? And version?

                    Please confirm the platform/module as well.

                    Is it possible for you to provide us the project file which include the minimal code for reproducing the issue. Also please let us know the clear steps to reproduce the issue.

                     

                    Thanks,

                    -Dheeraj

                    2 of 2 people found this helpful