You are here

How to add uart debug | Cypress Semiconductor

How to add uart debug

Summary: 4 Replies, Latest post by Graeme Parker on 13 Jul 2016 11:46 PM PDT
Verified Answers: 1
Last post
Log in to post new comments.
Graeme Parker's picture
36 posts


I am so lost!

I have been going through a few example projects for the BLE Pioneer Kit CY8CKIT-042. Starting with the BLE_battery_level which includes DBG_PRINTF.

Then I tried BLE_device_information_service which doesn't have DBG_PRINTF (debug via uart). Simple question, and I know it must be easy and I feel so stupid for not being able to do/find it - how do I add DBG_PRINTF to the BLE_dev_info_svc example? Do I add it as a component from a library, which comp, which lib?

My goal is to read log data from the PSoC into an Android phone. My android app can find the PSoC BLE device and print out its name and address, and I was hoping that the ble_dev_info_svc example would give me clues as to what to do next [unless there is a ready made example for what I want to do].

PS I'm new to OOP, Java, Android, and BLE - so have a lot to learn.


mady's picture
Cypress Employee
955 posts


I have added the DBG_PRINTF function to the Dev Info Service Project. Please find it attached.

The things I have modified are:

(i) Copied the UART Component in the cysch file in the Battery Level project to cysch file of Dev Info Service Project

(ii) In the system Tab in cydwr file, the Heap Size is incresed to 0x400 (to accomodate more complexity)

(iii) In the Pins Tab in cydwr file, make sure th UART RX and TX pins are mapped to P1.4 and P1.5 pins respectively. (On the pioneer kit, these pins are only connected to a USB - UART Converter)

(iv) Copy the debug.c file in the BatteryLevel project and paste it to the Dev Info Service Project

(v) Have a common main.h header file to link the debug.c file and main.c file. (So that main.c file may use the DBG_PRINTF function defined in debug.c)

(vi) In the main function in main.c, call UART_DEB_Start () API to start the UART.

You can now add the DBG_PRINTF function anywhere in your code to test the flow of the code. The Baud rate is 115200


-Madhu Sudhan

Graeme Parker's picture
36 posts

Thanks for your instructions.

Of course the issue I have now is that the UART and BLE don't want to play together! The UART baud rate and bits/char do not seem to match what they are set to. The UART receiver's baud rate can no doubt cope with a large difference to that set, but the bits/char seem not to be 8 as requested - which means the terminal output is jibberish.

ericwhitefield_1538151's picture
7 posts

I also had a similar issue sending some debug data from some BLE related functions over the UART. Just looked like garbage. One thing I realized was that the sleep modes were causing my issues with the UART data. In my case the sleep was tightly coupled with the BLE timing and couldn't be disabled easily. So I put a CyDelay(10) statement directly after sending the debug data. This allowed the UART time to send everything in the buffer and it worked fine. Not saying this is a solution one should leave in production code, but for a temporary debug output statement it got the job done.

Graeme Parker's picture
36 posts

Thanks very much. It works for me too.

As you say, probably not ideal to leave in after debugging is complete (I wonder will mine ever be).

Log in to post new comments.