3 Replies Latest reply on Aug 4, 2020 11:51 PM by AnjanaM_61

    puart rx callback is not working

    daba_4649501

      hello,

      i am using cybt-413034-02 module and i want to send and receive data through PUART , i can able to print the data but i cant able to write or read the data from call back function.

      i am using wiced studio 6.4 and version is WICED-SDK Version: Wiced_006.004.000.0061

       

      i am using this code and called test_puart_driver.

      please help,

      APPLICATION START()

      {

      test_puart_driver();

      }

      void puar_rx_interrupt_callback(void* unused)

      {

          // There can be at most 16 bytes in the HW FIFO.

          uint8_t  readbyte;

       

       

          wiced_hal_puart_read( &readbyte );

       

       

          /* send one byte via the TX line. */

          wiced_hal_puart_write( readbyte+1 );

       

       

          if( readbyte == 'S' )

          {

              /* send a string of characters via the TX line */

              wiced_hal_puart_print( "\nYou typed 'S'.\n" );

          }

          wiced_hal_puart_reset_puart_interrupt( );

      }

       

       

      /* Sample code to test puart driver. Initialises puart, selects puart pads,

      * turn off flow control, and enables Tx and Rx.

      * Echoes the input byte with increment by 1.

      */

      void test_puart_driver( void )

      {

          uint8_t read_5_bytes[5];

       

       

          wiced_hal_puart_init( );

       

       

          // Possible uart tx and rx combination.

          // Pin for Rx: p2, Pin for Tx: p0

          // Note that p2 and p0 might not be avaliable for use on your

          // specific hardware platform.

          // Please see the User Documentation to reference the valid pins.

      #if defined(CYW20706A2)

          wiced_hal_puart_select_uart_pads( WICED_PUART_RXD, WICED_PUART_TXD, 0, 0);

      #endif

       

       

          /* Turn off flow control */

          wiced_hal_puart_flow_off( );  // call wiced_hal_puart_flow_on(); to turn on flow control

       

       

          // BEGIN - puart interrupt

          wiced_hal_puart_register_interrupt(puar_rx_interrupt_callback);

       

       

      #if !defined(CYW20706A2)

          //set watermak level to 1 to receive interrupt up on receiving each byte

          wiced_hal_puart_set_watermark_level(1);

      #endif

       

       

          /* Turn on Tx */

          wiced_hal_puart_enable_tx( ); // call wiced_hal_puart_disable_tx to disable transmit capability.

          wiced_hal_puart_print( "Hello World!\r\nType something! Keystrokes are echoed to the terminal ...\r\n");

       

       

          /* Enable to change puart baud rate. eg: 9600, 19200, 38200 */

          wiced_hal_puart_set_baudrate( 115200 );

      }