Adding UART to BLE barebones sample project

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
mahaju
Offline
Last seen:2 years 1 month ago
加入:2018-01-29 01:08
Adding UART to BLE barebones sample project

I am trying to study about BLE using DA14580 using the DA14580 motherboard and the BLE barebones project

I think it is not possible to use printf() function for debugging using Keil (https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl...), so I am trying to add the UART feature from the Blinky sample program into the BLE barebones project

我添加了一组common_uart ble_app_barebone_580 in the Project tree view in Keil, and included common_uart.c in this group

The common_uart.c and common_uart.h files were added in the folder "...ble_app_barebone\src"

I have added the following lines in user_barebones.c
#include "common_uart.h"
printf_string("Entered user_app_adv_start\n");

It builds without any errors, but when I run the program after entering debug mode, it stops at the point

__asm("BKPT #0\n");

in nmi_handler.c

I didn't perform any initialization for the UART which I think might be causing this. So my questions are:

1. Is this the correct approach to adding UART in the barebones project?
2. Where is the main() function in the barebones project? I found int main_func(void){..} inside arch_main.c. Is this the main function? Is it safe to edit this file to add UART initialization code?
3. Am I correct in understanding that I cannot use printf() function to add diagnostic messages?

Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi mahaju,

Hi mahaju,

  1. Since the NMI occurs that means that the code is stuck somewhere, i dont think that it is because of the UART, anyway, in order to use uart printing on BLE projects you will have to:
    1. define the CFG_PRINTF in the da1458x_config_basic.
    2. use the arch_printf() API in order to print messages to the uart
    3. include the arch_console.h file in order to use the above API for printing messages
    4. make sure that the pins used from UART2 are connected to your FTDI chip the default pin are from PORT2 the PIN6 and PIN7.
  2. The main function of the BLE projects is in arch_main.c function and is the main_func(), dont use this function for UART initialization, using the above method the SDK will make all the proper initializations for the UART.
  3. Yes, you cannot use the standard printf implementation.

Thanks MT_dialog

mahaju
Offline
Last seen:2 years 1 month ago
加入:2018-01-29 01:08
Hello

Hello

Thank you for the quick reply
I added
1) #define CFG_PRINTF in da1458x_config_basic.h, after the line #undef CFG_PRINTF that was already there
2) #include "arch_console.h" in user_barebone.c and
3) arch_printf("Entered user_app_adv_start\n"); inside the function void user_app_adv_start(void)

I was hoping that when BLE advertisement starts I would see something on TeraTerm, but I don't see anything

I see a few lines of gibberish when the program starts, but nothing after that

I have set the baud rate and com port to the same values that I would use with the Blinky sample program

I am however, not sure about what you meant by point 4 in your earlier reply. I have left all the jumpers on the board in their default locations, the same settings that the board had when I received it ( I have attached a screen shot of my current jumper locations). The Blinky sample works without any jumper modifications

After having a look at the schematics document ("E-da14580devkt-p_vb_schematic.pdf" in page 1) I tried connecting pins 7 and 8 of J8 on my motherboard (DA14580DEVKT-P_VC, current daughterboard is DA14580ATDB-P, but I need this work for the WLCSP34 daughterboard as well) thinking that would connect PORT2 pins 6 and 7, but the UART is still not working

What could be the problem? Alternatively, is it possible to use the UART without any hardware changes to the motherboard, using the same hardware and software settings being used in the Blinky program?

--- EDIT ---

This problem has been solved by connecting pin 7 of J7 to 12 of J5, and pin 8 of J7 to 14 of J5
The UART output shows up on the smaller of the two virtual serial ports
All the software modifcations mentioned above have been made
(motherboard is DA14580DEVKT-P_VC, daughter board is DA14580ATDB-P)

** NEW QUESTION **
I would still like to know whether it is possible to enable UART in the BLE projects without having to make any hardware modifications, same as in the Blinky program. I would also like to know if my current hardware configuration will work the same way, if the daughter board is replaced with the WL-CSP34 daughter board.

Attachment:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi mahaju,

Hi mahaju,

The jiberish that you see when start the debug session is just the bootloader executing after the JTAG resets the board.

4点我上面提到的是什么改变the default UART2 pins from (since the default printing utility uses the UART 2 and the default pins are P26 and P27) so this is where the printing goes, so you have two options either connect the on board FTDI pins with the above mentioned pins or change the pins configuration and use instead of of P26 and P27 the pins P04 and P05 as TX and RX respectively (check the UART2_TX/RX_GPIO_PORT and UART2_TX/RX_GPIO_PIN in the user_periph_setup.h file). With the latter method you dont have to change any configuration on the pro kit and keep the jumper configuration as is on the attachment.

I suppose that the above statement answers to your question, in the case of WL-CSP34, this wont work since that package doesn't have a PORT2 pins but only PORT0 and PORT1 so the above method will also work for the CSP package.

Thanks MT_dialog