How to utilize debug printing?

6 posts / 0 new
Last post
VesaN
Offline
Last seen:5 years 4 months ago
Guru Master
加入:2014-06-26 08:49
How to utilize debug printing?

Hello,

I want to be able to print to serial monitor from my project. How to do it? I want to have similar functions as utilized in peripherals example but it says (Do not use for your designs).

Best regards, Vesa

VesaN
Offline
Last seen:5 years 4 months ago
Guru Master
加入:2014-06-26 08:49
Hi,

Hi,

I still need the answer. Any advices?

BR, Vesa

VesaN
Offline
Last seen:5 years 4 months ago
Guru Master
加入:2014-06-26 08:49
I try adding the uart.c to my

I try adding the uart.c to my project and including the driver path in project include paths. I cannot compile the project then, and I get many errors:
. . \ \…\ src \ plf \ refip \ src\driver\uart\uart.c(290): error: #101: "uint32_t" has already been declared in the current scope
extern const uint32_t jump_table_struct[];
. . \ \…\ src \ plf \ refip \ src\driver\uart\uart.c(290): error: #65: expected a ";"
extern const uint32_t jump_table_struct[];
. . \ \…\ src \ plf \ refip \ src\driver\uart\uart.c(296): error: #18: expected a ")"
PtrFunc = (my_function)(jump_table_struct[uart_init_pos]);
. . \ \…\ src \ plf \ refip \ src\driver\uart\uart.c(346): error: #18: expected a ")"
PtrFunc = (my_function)(jump_table_struct[uart_flow_on_pos]);
...

JE_Dialog
Offline
Last seen:19 hours 31 min ago
工作人员
加入:2013-12-05 14:02
Sorry for delay, i will get

Sorry for delay, i will get someone to look at this . BR JE_Dialog

RvA
Offline
Last seen:1 week 1 day ago
工作人员
加入:2014-02-07 14:10
Hi Vesa,

Hi Vesa,
Have you looked at our Serial Port Service reference design? It is a DA14580 Serial Port Service reference application, emulating the serial cable communication. This might be a good fit to your serial monitor project.
Best regards,
RvA (Dialog)

VesaN
Offline
Last seen:5 years 4 months ago
Guru Master
加入:2014-06-26 08:49
Thanks RvA,

Thanks RvA,

I managed to resolve this finally. For some reason, the printing doesn't yet work with my own project, which is a copy of template_fh, i just included battery service. The printing works with template_fh:

  1. I definedCFG_PRINTFinda14580_config.hon line ~30. This definition will make GPIO reservations and configures GPIO inperiph_setup.c:
    periph_setup.c

    #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
    //
    #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, INPUT, PID_UART2_RX, false );
    #endif
  2. Inperiph_init()function: one must enable the UART clock and also uart init can be executed:
    periph_setup.c

    #ifdef CFG_PRINTF_UART2
    SetBits16(CLK_PER_REG, UART2_ENABLE, 1);
    uart2_init(UART_BAUDRATE_115K2, 3);
    #endif
  3. Then I made macro definition inapp_template_proj.caccording to the UM-B-004:
    app_template_proj.c

    #define DBG_PRINT(str) \
    uart2_flow_on(); \
    uart2_flow_off(); \
    uart2_finish_transfers(); \
    uart2_write((uint8_t *)str, sizeof(str), NULL)
  4. I'm not sure about the flow control and FTDI but it's working.

edit:I noticed I accidentally used uart_finish_transfers() instead of uart2_finish_tranfers() in above. This is fixed now and everything seems working to me with the method above. For some reason it compiled in both cases even uart.c was not included in my project (where the uart_finish_tranfers() function is implemented).

Topic locked