BLE App with UART for debug messages

3 posts / 0 new
Last post
rydello
Offline
Last seen:4 years 5 months ago
加入:2015-10-29 16:51
BLE App with UART for debug messages

Is there an SDK 5.0.3 example BLE project (target_app) that uses the UART for debug? The peripheral examples at "\projects\target_apps\peripheral_examples" use "\projects\target_apps\peripheral_examples\shared\common_uart\common_uart.c" which contains the note: "(Do not use for your designs) - (legacy)" and the BLE example projects I have found do not use printf debugging so I'm not sure how to "add" printf debugging to the BLE examples.
Thank you.

Device:
MT_dialog
Offline
Last seen:2 months 1 week ago
Staff
加入:2015-06-08 11:34
Hi rydello,

Hi rydello,

Please check below, based on the SKD5 template the steps that are required in order to achieve a printing functionallity over UART:

1) In the da1458x_config_basic.h file define the CFG_PRINTF_UART2.

2) In the user_periph_setup.h change the default pins to P0_4 for TX and P0_5 for RX

3) Make the following change in the schedule_while_ble_on:

//grant control to the application, try to go to sleep
//if the application returns GOTO_SLEEP
if (app_asynch_trm())
{
continue; // so that rwip_schedule() is called again
}
else
{
arch_printf_process();
break;
}

4)在user_callback_config.h。pp_on_ble_powered replace the NULL value with a custom function e.x. user_app_on_ble_powered

5) Declare and implement the user_app_on_ble_powered function in the empty_peripheral_template.h file as below:

implementation: enum arch_main_loop_callback_ret user_app_on_ble_powered(void) { return KEEP_POWERED; }

6) Include the "arch_console.h" file that provides the printf functionality.

7) Use the arch_puts in order to print data to your uart.

Thanks MT_dialog

rydello
Offline
Last seen:4 years 5 months ago
加入:2015-10-29 16:51
Thank you. I am now able to

Thank you. I am now able to see my uart debug output messages. I have ensured that CFG_PRINTF and CFG_PRINTF_UART2 are defined, I modified the definition of the UART2 TX and RX port/pins and implemented a user_app_on_ble_powered() callback. However, the suggested changes in schedule_while_ble_on() did not seem to work since arch_printf_process() is only called if user_app_on_ble_powered() returns a false (0) value. I left the code as-is which seems to work:
//grant control to the application, try to go to sleep
//if the applciation returns GOTO_SLEEP
if (!app_asynch_trm())
break;

//SDKIMPROVEMENTS Needs testing!! We can add the following condition and move
// it out of the loop
// we may consider putting it in before the app_asynch_trm
//if (GetBits16(CLK_CTRL_REG, RUNNING_AT_XTAL16M))

// execute the printf process
arch_printf_process();

Thanks!

Topic locked