How can I add uart(printf) to the project (reporter_fh )to print MSG for debuging

12 posts / 0 new
Last post
zqinglin
Offline
Last seen:6 years 7 months ago
对未来ned:2014-07-02 08:11
How can I add uart(printf) to the project (reporter_fh )to print MSG for debuging

现在项目报告_FH可以运行。使用IPNONE可以发现DA14580。但是我想添加uart.c,就像项目的peripheral_examples一样,可以将msg打印到pc。如何将UART(PRINTF)添加到项目(Reporter_FH)以打印MSG以进行调试。

MHv_Dialog
Offline
Last seen:1 month 4 weeks ago
Staff
对未来ned:2013-12-06 15:10
Hi,

Hi,

This should help you get started:

uart_init(UART_BAUDRATE_115K2,3);
uart_flow_off();
uint8_t something[] = { 0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0D,'R','e','a','d','y',0x0D,0x0A,'>' } ;
uart_write(something,24,NULL);
uart_finish_transfers();

I hope it helps you,

zhangwen
Offline
Last seen:6 years 8 months ago
对未来ned:2014-04-15 14:29


i also want to add uart to the project(reporter_fh) to print some message,if you have added uart to that project successfully,please tell me ,What should I do.

VesaN
Offline
Last seen:5年6个月前
格鲁鲁 Master
对未来ned:2014-06-26 08:49
Hi,

Hi,

what is the difference between uart2.c and uart.c in the driver directory?

Best regards, Vesa

edit: I'm trying to print to serial monitor with DA14580. I defined CFG_PRINTF and included uart2.c in my project file. Then I copied the code above to my project source file but I didn't receive the message in my monitor. Can I have more detailed instructions?

asmaith.
Offline
Last seen:5 years 3 months ago
Expert
对未来ned:2014-11-20 08:45
你好,

你好,
Even I want to print some debug statements in app_init_func in file : fh_proxr_sdk.c in reporter_fh project.
I added uart.c and uart.h from peripheral_examples project, but since SPI_DI and UART_RX are sitting on same PORT and same PIN, I disabled BLE_SPOTA_RECEIVER profile in da14580_config.h file.
Now the code is getting flashed, but I am unable to see any Debug MSGS.

Thanks
asm

VesaN
Offline
Last seen:5年6个月前
格鲁鲁 Master
对未来ned:2014-06-26 08:49
Hi asmaitha,

Hi asmaitha,

I recommend you to use app_console with printing rather than make your own uart manipulation operations. This should somewhat work:

  1. Add#define CFG_PRINTFinda14580_config.h
  2. Include app_console in your project include paths:..\..\..\src\modules\app\src\app_utils\app_console
  3. Go to your project view and right clickapp/folder. Then, click Add existing file to Group 'app' and addapp_console.c
  4. Include fileapp_console.hwhere you want to use it:#include "app_console.h"
  5. 使用功能arch_printfto print text

It is important that you defined right UART pins!Do it inperiph_setup.cfile inarch/folder:

Reserve GPIO inGPIO_reservationsfunction with following macros:

#ifdef CFG_PRINTF_UART2
RESERVE_GPIO( UART2_TX, GPIO_PORT_0, GPIO_PIN_4, PID_UART2_TX);
RESERVE_GPIO( UART2_RX, GPIO_PORT_0, GPIO_PIN_5, PID_UART2_RX);
#endif

and inset_pad_functionsfunction


#ifdef CFG_PRINTF_UART2
GPIO_ConfigurePin(GPIO_PORT_0, GPIO_PIN_4, OUTPUT, PID_UART2_TX, false);
gpio_configurepin(gpio_port_0,gpio_pin_5,输入,pid_uart2_rx,false);
#endif

Thanks

asmaith.
Offline
Last seen:5 years 3 months ago
Expert
对未来ned:2014-11-20 08:45
你好,视频电子设备标准协会,

你好,视频电子设备标准协会,
In spite of doing all the above mentioned changes I am still unable to see any debug MSGS on console.
I used included a statement arch_printf("Hello"); inside app_init_func

Thanks
asm

VesaN
Offline
Last seen:5年6个月前
格鲁鲁 Master
对未来ned:2014-06-26 08:49
Hello asmaitha,

Hello asmaitha,

Can you give more details of what goes wrong? Does the program compile? What hardware are you using? What is your pin configuration?

Are you sure you have following lines in your da14580_config.h and did you check you don't have#undef CFG_PRINTFafter that?


/*UART Console Print*/
#define CFG_PRINTF
#ifdef CFG_PRINTF
#define CFG_PRINTF_UART2
#endif

Thanks!

asmaith.
Offline
Last seen:5 years 3 months ago
Expert
对未来ned:2014-11-20 08:45
你好,视频电子设备标准协会,

你好,视频电子设备标准协会,
In da14580_config.h
#define CFG_PRINTF
#define CFG_PRINTF_UART2
have been defined.

But I still have a bsic doubt :
in periph_setup.c file :
#if (BLE_SPOTA_RECEIVER)
RESERVE_GPIO( SPI_CLK, GPIO_PORT_0, GPIO_PIN_0, PID_SPI_CLK);
RESERVE_GPIO( SPI_DO, GPIO_PORT_0, GPIO_PIN_6, PID_SPI_DO);
RESERVE_GPIO( SPI_DI, GPIO_PORT_0, GPIO_PIN_5, PID_SPI_DI);
RESERVE_GPIO( SPI_EN, GPIO_PORT_0, GPIO_PIN_3, PID_SPI_EN);
#endif

#ifdef CFG_PRINTF_UART2
RESERVE_GPIO( UART2_TX, GPIO_PORT_0, GPIO_PIN_4, PID_UART2_TX);
RESERVE_GPIO( UART2_RX, GPIO_PORT_0, GPIO_PIN_5, PID_UART2_RX);
#endif

So here Between UART2_RX and SPI_DI, there is a clash, which means UART ports initialization doesn't happen at all rite...

Thanks
asm

VesaN
Offline
Last seen:5年6个月前
格鲁鲁 Master
对未来ned:2014-06-26 08:49
Hi asmaitha,

Hi asmaitha,

实际上,GPIO预留宏完全无关紧要。他们只是看到没有冲突。更重要的是你的关系GPIO_ConfigurePinfunctions. And you obiviously have a conflict with SPI bus, things won't work then!

asmaith.
Offline
Last seen:5 years 3 months ago
Expert
对未来ned:2014-11-20 08:45
Hello VesaN,

Hello VesaN,
Thanks a lot.

Thanks
asm

LittleBee
Offline
Last seen:4 years 4 months ago
对未来ned:2015-07-13 08:38
对不起,我不是什么新鲜事

对不起,我不是什么新鲜事getting irritated. Anyone have a working example of SmartTag with functional UART string write out for the basic board. I've been play with VesaN step by step example and tweaking it along with other examples for uart. but i keep running into __asm("BKPT #0\n"); // this pin has not been previously reserved!.. or not working at all. I even starting going to town delete everything related to pin reserve but still stuck.