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

我正在尝试使用DA14580使用DA14580主板和BLE Barebones项目进行关于BLE

I think it is not possible to use printf() function for debugging using Keil (https://support.dialog-semicondiondiondum/forums/post/dialog-smartbond-bl ...),所以我试图将眨眼样本程序中的UART功能添加到BLE Barebones项目中

我添加了一组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(“输入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
嗨马哈茹,

嗨马哈茹,

  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. 使用ARCH_PRINTF()API才能将消息打印到UART
    3. include the arch_console.h file in order to use the above API for printing messages
    4. 确保从UART2使用的引脚连接到您的FTDI芯片默认引脚来自PIN6和PIN7。
  2. BLE项目的主要功能在ARCH_MAIN.c函数中,并且是MAIN_FUNC(),不要使用此功能为UART初始化,使用上面的方法SDK将为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在da1458x_config_basic.h中,之后的#undef cfg_printf已经存在
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)

我希望当BLE广告开始时,我会在Teraterm上看到一些东西,但我没有看到任何东西

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

我已经将波特率和COM端口设置为与Blinky示例程序一起使用的相同值

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
嗨马哈茹,

嗨马哈茹,

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

在第4点中提到的我在4中提到的是改变默认的UART2引脚(因为默认打印实用程序使用UART 2,默认引脚为P26和P27),因此这是打印的位置,因此您可以连接两个选项具有上面提到的引脚的on LoSt FTDI引脚或将引脚配置和使用代替P26和P27作为TX和Rx的PIN P04和P05(检查UART2_TX / RX_GPIO_PORT和UART2_TX / RX_GPIO_PIN))。使用后一种方法,您不必在Pro套件上更改任何配置,并将跳线配置保持在附件上。

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