Note: This KBA has been marked as deprecated. A more updated KBA can be found here:Using Low-Energy UART
Introduction
The LEUART provides full UART communication running from a 32.768 kHz clock input. It allows UART communication down to EM2 as well as data transmission and reception using DMA.
Changing the WSTK Baud Rate
The LEUART is limited to 9600 baud due to the low frequency clock that it runs from. If you want to try this example using the WSTK VCOM, we need to change its baud rate from the default 115200. It's also possible to simply connect an external UART<->USB converter instead of using the VCOM, in which case these instructions are not needed.
To change the WSTK VCOM settings we need to connect to the WSTK via serial port to access the board controller.
To change the settings through serial connection, we can use the console in Simplicity Studio:
Plugin your device and right-click on it in the "Debug Adapters" pane.
Select "Launch Console" and navigate to the "Admin" tab.
Once the console session is opened you’ll be shown the WSTK command prompt. If you write serial vcom it will print out the existing settings.
Finally, to configure the settings you need to run the command serial vcom config handshake disable speed 9600. The output of the command can be seen in the picture below.
Application Project Setup
Create a new SoC - Empty project for your device.
Copy the dmadrv folder, em_leuart.h/c and em_ldma.h/c files from the SDK directories (C:\SiliconLabs\SimplicityStudio\versionX\developer\sdks\gecko_sdk_suite\versionY\platform) to the project platform/emdrv/ and platform/emlib/ directories respectively.
Add the included files to the project include paths (E.g. for GCC: right-click on the project -> Properties -> "C/C++ Build" -> Settings -> "GNU ARM C Compiler" -> Includes): "${workspace_loc:/${ProjName}/platform/emdrv/dmadrv/inc}"
Replace the existing app.c with the one attached here.
Change the device name to "LEUART Example" in the GATT Configurator (.isc) or import the attached gatt.xml. Remember to Save and Generate when you change anything.
Build and flash the project.
Running the example
This example makes use the LEUART Start Frame and Signal Frame features. Essentially these allow the LEUART to generate an interrupt upon receiving a pre-configured byte allowing enhanced energy savings and more fine control over what gets read by the LEUART. Briefly this is how the examples operates:
Upon startup the device will be advertising with the device name LEUART example and it will go into EM2 in between advertisements. The LEUART will be active waiting for the start frame, which is the character *, all other bytes are blocked.
Once the start frame is received an interrupt is generated and the string "Start Frame" is printed out using DMA. An additional DMA channel is setup to read incoming data to the LEUART.
When the signal frame # is received the data read by the DMA is used to set the new device name and the device name is also printed out of the LEUART.
Device goes back into blocking other bytes and waiting for the start frame -> go back to (2)
Note: The DMA will only copy 20 bytes after the start frame (including the signal frame) so if more bytes are sent then the 21st byte will have the same functional effect as sending the signal frame so that the LEUART doesn't become blocked.
Here is a screenshot showing what happens in the terminal when we send "*My Device#" into the LEUART (*My Device# is sent to the LEUART and echoed on the terminal). A scanning device would see the device name as being My Device.
And here is the Energy Profiler with the larger current spike corresponding to the LEUART activity.
[Deprecated] KBA_BT_1001: Using the LEUART
Note: This KBA has been marked as deprecated. A more updated KBA can be found here: Using Low-Energy UART
Introduction
The LEUART provides full UART communication running from a 32.768 kHz clock input. It allows UART communication down to EM2 as well as data transmission and reception using DMA.
Changing the WSTK Baud Rate
The LEUART is limited to 9600 baud due to the low frequency clock that it runs from. If you want to try this example using the WSTK VCOM, we need to change its baud rate from the default 115200. It's also possible to simply connect an external UART<->USB converter instead of using the VCOM, in which case these instructions are not needed.
To change the WSTK VCOM settings we need to connect to the WSTK via serial port to access the board controller.
To change the settings through serial connection, we can use the console in Simplicity Studio:
Once the console session is opened you’ll be shown the WSTK command prompt. If you write serial vcom it will print out the existing settings.
Application Project Setup
C:\SiliconLabs\SimplicityStudio\versionX\developer\sdks\gecko_sdk_suite\versionY\platform
) to the projectplatform/emdrv/
andplatform/emlib/
directories respectively."${workspace_loc:/${ProjName}/platform/emdrv/dmadrv/inc}"
Running the example
This example makes use the LEUART Start Frame and Signal Frame features. Essentially these allow the LEUART to generate an interrupt upon receiving a pre-configured byte allowing enhanced energy savings and more fine control over what gets read by the LEUART. Briefly this is how the examples operates:
Here is a screenshot showing what happens in the terminal when we send "*My Device#" into the LEUART (*My Device# is sent to the LEUART and echoed on the terminal). A scanning device would see the device name as being My Device.
And here is the Energy Profiler with the larger current spike corresponding to the LEUART activity.