1 Reply Latest reply on Apr 19, 2017 7:16 AM by jrow

    How to configure UART(Baud rate,start,stop bits..)




      I want to replace serial link with BLE module in my project. Microcontroller acts as host ,which communicates directly with BLE module i.e Peripheral through UART .Smartphone will have an app ,which acts as client and fetch the data sent by server. 


      I have read the Serial BLE firmware platform user guide.Hence I came to know that BLE can be configured using "API protocol in text mode" and " API protocol in binary mode."


      Usually UART uses CYSPP mode.If microcontroller is acting as host,it is best to use "API protocol in binary mode".


      Know my doubt is how to change the UART settings,Advertising timeout using Binary mode.


      In some BLE's, ATI commands are used to configure the UART settings.


      How can we implement this in  CYBLE-022001-00 using "API binary mode".

        • 1. Re: How to configure UART(Baud rate,start,stop bits..)

          Hi Priyanka,


          All text-mode commands have an exact binary-mode equivalent which will cause the exact same result. The commands you would use to change UART parameters and default advertising timeout are system_set_uart_parameters ("STU" in text mode) and gap_set_adv_parameters ("SAP" in text mode). The structures of these commands are documented in the current Rev. *C of the User Guide on pages 97-99 and page 117, respectively. Make sure you read through all of the binary mode protocol characteristics in Section and the text/binary similarities and differences listed in Section 2.4.3 to avoid any incorrect assumptions about how each mode works.


          Also, note that UART settings in particular fall within the "protected" setting category, meaning it is not possible to directly write changed settings to flash before first writing them to RAM. This two-step process ensures that you do not accidentally lock yourself out of communication by permanently storing a communication setting that your external host cannot use. You must first write the new settings in RAM, then switch the host UART to match the new settings, then write the new settings to flash. If the host is unable to use the new settings applied in the first step, a simple soft reset with XRES or power-cycle will return the module to its previous state (115200,8/N/1 if using factory defaults). Protected settings are documented in Section 2.5.3 on page 26 of the User Guide.


          For example, if you wanted to change the baud rate from 115200 to 9600 (keeping 8 data bits, no parity, 1 stop bit, no flow control) and then store it in flash, you should do the following:

          1. Set host at 115200 baud
          3. Send system_set_uart_parameters binary command: =>[C0 0A 02 19 80 25 00 00 00 00 00 08 00 01 2C]
          5. Parse system_set_uart_parameters binary response: <=[C0 02 02 19 00 00 76]
          7. Change host to 9600 baud
          9. Send system_store_config binary command: =>[C0 00 02 04 5F]
          11. Parse system_store_config binary response: <=[C0 02 02 04 00 00 61]

          After this, the module will boot at 9600 baud and remain there unless you change it again or trigger a factory reset through an API command or GPIO signals.