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).
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]); ...
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)
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:
I definedCFG_PRINTFinda14580_config.hon line ~30. This definition will make GPIO reservations and configures GPIO inperiph_setup.c:
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).
Hi,
I still need the answer. Any advices?
BR, Vesa
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]);
...
Sorry for delay, i will get someone to look at this . BR JE_Dialog
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)
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:
CFG_PRINTF
inda14580_config.h
on 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
periph_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
app_template_proj.c
according 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)
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).