1 Reply Latest reply on Jul 9, 2015 4:26 AM by kmiacle

    BCM920732  UART missing bytes

      Dear All,


      I am using BCM920732  to develop a uart app.

      Now I have encountered a problem, my puart always lost data even though I only want to receive 6 bytes.


      I read the article as bleow. disable the sleep mod.



      but it's not working for me.


      Can someone advice me how to solve it?



      my code are as below:


      // fix for puart.h - found in ws_upgrade_uart.h - have no idea if that's right.

      extern BLECM_FUNC_WITH_PARAM puart_bleRxCb;



      INT32 application_puart_interrupt_callback(void* unused);


      // holds the callback function when a packet is read.




      // Callback called by the FW when ready to sleep/deep-sleep. Disable both by returning 0

      // so the UART will always receive bytes.

      UINT32 ws_upgrade_uart_device_lpm_queriable(LowPowerModePollType type, UINT32 context)


        // Disable sleep.

        return 0;





      * Inits the PUART with the given RX callback.


      void uart_init(FUNC_ON_UART_RECEIVE callback) {

        extern puart_UartConfig puart_config;



        // Do all other app initializations.

        // Set the baud rate we want to use. Default is 115200.

        puart_config.baudrate = PUART_BAUD_RATE;


        // Select the uart pins for RXD, TXD and optionally CTS and RTS.

        // If hardware flow control is not required like here, set these

        // pins to 0x00. See Table 1 and Table 2 for valid options.

        puart_selectUartPads(PUART_RX_PIN, PUART_TX_PIN, 0x00, 0x00);



        // Initialize the peripheral uart driver




        // Since we are not configuring CTS and RTS here, turn off // hardware flow control. If HW flow control is used, then // puart_flowOff //should not be invoked.








        /* BEGIN - puart interrupt

        The following lines enable interrupt when one (or more) bytes

        are received over the peripheral uart interface. This is optional.

        In the absence of this, the app is expected to poll the peripheral uart to pull out received bytes.



        // clear interrupt




        // set watermark to 1 byte - will interrupt on every byte received.




        // enable UART interrupt in the Main Interrupt Controller and RX Almost Full in the UART // Interrupt Controller




        // Set callback function to app callback function.

        puart_bleRxCb = application_puart_interrupt_callback;



        // also register a listener from the caller

        onReceiveCB = callback;



        // Enable the CPU level interrupt






        /* END - puart interrupt */



        // disable sleep mode: the PUART does not work if the device is asleep



        // Since we are not using any flow control, disable sleep when download starts.

        // If HW flow control is configured or app uses its own flow control mechanism,

        // this is not required.

        devlpm_registerForLowPowerQueries(ws_upgrade_uart_device_lpm_queriable, 0);


        // print a string message assuming that the device connected

        // to the peripheral uart can handle this string.

        //ble_trace0("Application initialization complete!");



      INT32 application_puart_interrupt_callback(void* unused) {

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

        char readbytes[16];

        UINT8 number_of_bytes_read = 0;



        // empty the FIFO

        while(puart_rxFifoNotEmpty() && puart_read(&readbytes[number_of_bytes_read])) {


        if(readbytes[number_of_bytes_read]!= 0x61)

        ble_trace2("\n No: %d  puart read: %x \n",number_of_bytes_read,readbytes[number_of_bytes_read]);



        ble_trace1("\n %d byte received \n",number_of_bytes_read);

        // readbytes should have number_of_bytes_read bytes of data read from puart. Do something with this.

        //ble_trace1("application_puart_interrupt_callback:number_of_bytes_read  %d \n",number_of_bytes_read);




        // clear the interrupt




        // enable UART interrupt in the Main Interrupt Controller and RX Almost Full in the UART Interrupt Controller



        return 0;