9 Replies Latest reply on Jul 10, 2015 10:20 AM by gdepaula

    UART Problem



      I am having a WICED BCM943362 board. I am using it for communicating with an external device on RS 485 (MODBUS RTU Protocol) through UART. The IC used for converting the RS485 voltage level to CMOS (3.3v) is SN75HVD12  Half duplex tranceiver IC.


      I am sending command to the device through UART and the device responds. This is happening properly for sometime. But after sometime I am getting All Zero Response from the device . For example


      TX (command)                   : 01 03 00 64 00 02 85 d4

      RX (Response from device) : 01 03 04 00 00 00 00 fa 33


      TX (command)                   : 01 03 00 64 00 02 85 d4

      RX (Response from device) : 01 03 04 00 00 00 00 fa 33


      TX (command)                   : 01 03 00 64 00 02 85 d4

      RX (Response from device) : 00 00 00 00 00 00 00 00 00


      TX (command)                   : 01 03 00 64 00 02 85 d4

      RX (Response from device) : 01 03 04 00 00 00 00 fa 33


      TX (command)                   : 01 03 00 64 00 02 85 d4

      RX (Response from device) : 00 00 00 00 00 00 00 00 00

      I am pretty sure the device is responding properly (there is Indication that data is sent). I suspect there is some problem in UART communication. If there problem with the code I have written, then I should not get correct response all the time. But why this inconsistent behaviour?


      Please help me in this regard.



        • 1. Re: UART Problem


          Do you still have issues on receiving data? If so, could you please monitor communication on the RS485 with external device?

          • 2. Re: UART Problem

            Hi seyhan,


            Thanks for the reply. Yes I still have problem in receiving data. I am monitoring the communication with CRO. I see the incoming bytes from the external device. But the board is not able to receive properly.


            I am also facing another similar problem which I have posted here.

            Inconsistent UART receive problem


            Can u help me on that also ?


            I have attached a picture of CRO capture.


            Blue - Transmit

            Pink - Receive

            yellow - Direction control (IC is Half duplex)


            Thanks in advance.

            • 3. Re: UART Problem

              We don't have access to RS485 setup or equipment. So this is a bit outside the scope of the WICED SDK Forum. Have you made progress on your own?  Do you have any follow up?

              • 4. Re: UART Problem



                We are testing this issue. I have posted in here.

                Inconsistent UART receive problem


                But while testing i faced some TCP issue which I have posted in a different thread.

                TCP Server hangs after sometime



                • 5. Re: UART Problem

                  Hi GregG_16 and SeyhanA_31 .


                  In The UART example you given  by seyhan,

                  UART Setup and UART Messages Over Webpage .



                  I have followed the same But I am not able to compile the program after performing the Steps you have guided.


                  I am using WICED-SDK 3.1.2 and using EVAL Board - BCM943362WCD4 .


                  Please guide me into this.



                  Thanking You

                  • 6. Re: UART Problem

                    hi SeyhanA_31 ,
                    Is there any update for the above problems..



                    Please Reply if you have any solutions.






                    Thanking You,


                    • 7. Re: UART Problem

                      Hi SeyhanA_31


                      Is there any update regarding above issue..

                      • 8. Re: UART Problem

                        Hi SeyhanA_31 GregG_16


                        I am Facing an Issue over UART.
                        I have setup in that, WIced uart is connected with Another Controllers UART.
                        As when I start Communication, The First Byte that I Received on another Controller is Garbage.
                        I have debug in that issue and Found that when UART is Initialized, It sends the Garbage byte.

                        After first Garbage byte the other communication is seems to free flow.


                        My code is below.

                        #include "wiced.h"



                        #define RX_BUFFER_SIZE    128

                        #define TEST_STR          "\r\nThis program will loop back characters via BLE ...\r\n> "


                        // Configuration for the UART


                        wiced_uart_config_t uart_config =


                            .baud_rate    = 38400,

                            .data_width   = DATA_WIDTH_8BIT,

                            .parity       = NO_PARITY,

                            .stop_bits    = STOP_BITS_1,

                            .flow_control = FLOW_CONTROL_DISABLED,



                        // Initialization for the Buffer


                        wiced_ring_buffer_t rx_buffer;

                        uint8_t  rx_data[RX_BUFFER_SIZE];


                        /* Main Application Start */

                        void application_start( )


                            // Variable of Loop Count for sending BLE Command

                            uint8_t loopCnt;


                        // Debuging By consol is ON

                        // Compare the String For Result

                            int32_t strCmpResult;

                        uint8_t startBleCmd2[20] = {0x01,0x01,0x02,0x08,0x08,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x23,0xfb};//0x02,0x01,0x02,0x08,0x08};

                        /*Storage for the Received DATA - 20 Bytes */

                            char recvData[20];

                        //Clear the Buffer of Receive data

                        /* Initialise the WICED device */


                        //Initialize LED1 for indication



                        wiced_result_t result;


                        /* Initialise ring buffer */

                        ring_buffer_init(&rx_buffer, rx_data, RX_BUFFER_SIZE );


                        /* Initialise UART. A ring buffer is used to hold received characters */

                            wiced_uart_init( WICED_UART_1, &uart_config, &rx_buffer );


                            /* Send a test string to UART */

                          //  wiced_uart_transmit_bytes( WICED_UART_1, startBleCmd2, 20 );


                           // wiced_rtos_delay_milliseconds(100);

                           //Wait for user input. If received, echo it back to the terminal

                                if(wiced_uart_receive_bytes(WICED_UART_1, recvData, sizeof(recvData), WICED_NEVER_TIMEOUT ) == WICED_SUCCESS ){}


                        ( baud rate and UART settings on both the controllers are same)

                        can you please suggest me on this matter, that why at time of UART initialization, First byte sent is garbage.
                        What steps should i need to take care.






                        • 9. Re: UART Problem

                          Hi Hinesh,


                          Try clearing the UART TX (Transmit) interrupt flag before initializing the port.  In some cases, I've seen the UART send a garbage byte at power up if by any change the Tx Int flag default power up value is pending.