Hi,
I would like to obtain printf and NRF_LOG separately from two TX ports.
I made a test application of serial output based on blinky.
P0.06:TX (and P0.08:RX) were connected to the PC with a USB serial dongle.
Also, I use the other USB serial dongle to make the P.0.04:TX signal visible on the PC.
Within pca 10056.h:
#define RX_PIN_NUMBER 8 #define TX_PIN_NUMBER 6
And in sdk_config.h:
#define RETARGET_ENABLED 1 #define NRF_LOG_BACKEND_UART_ENABLED 1 #define NRF_LOG_BACKEND_UART_TX_PIN 4
I am doing. It is as follows as main.c.
#include <stdbool.h>
#include <stdint.h> #include "nrf_delay.h" #include "boards.h" #include "nrf_log.h" #include "nrf_log_ctrl.h" #include "nrf_log_default_backends.h" #include "app_uart.h" #if defined (UART_PRESENT) #include "nrf_uart.h" #endif #if defined (UARTE_PRESENT) #include "nrf_uarte.h" #endif #define UART_TX_BUF_SIZE 256 #define UART_RX_BUF_SIZE 256 #define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED void uart_error_handle(app_uart_evt_t * p_event) { if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR) { APP_ERROR_HANDLER(p_event->data.error_communication); } else if (p_event->evt_type == APP_UART_FIFO_ERROR) { APP_ERROR_HANDLER(p_event->data.error_code); } } static void uart_init(void) { uint32_t err_code; const app_uart_comm_params_t comm_params = { RX_PIN_NUMBER, TX_PIN_NUMBER, RTS_PIN_NUMBER, CTS_PIN_NUMBER, UART_HWFC, false, NRF_UART_BAUDRATE_115200 }; APP_UART_FIFO_INIT(&comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_error_handle, APP_IRQ_PRIORITY_LOWEST, err_code); APP_ERROR_CHECK(err_code); } int main(void) { int counter=0; APP_ERROR_CHECK(NRF_LOG_INIT(NULL)); NRF_LOG_DEFAULT_BACKENDS_INIT(); uart_init(); bsp_board_init(BSP_INIT_LEDS); while (true) { for (int i = 0; i < LEDS_NUMBER; i++) { bsp_board_led_invert(i); nrf_delay_ms(50); } printf("count:%d\n",counter); NRF_LOG_INFO("%d",counter); NRF_LOG_FLUSH(); counter++; } }
Here, when I comment out
uart_init();
, it is output from P0.04 as follows.
<info> app: 0
<info> app: 1
<info> app: 2
<info> app: 3
<info> app: 4
And, when I comment out
APP_ERROR_CHECK(NRF_LOG_INIT(NULL)); NRF_LOG_DEFAULT_BACKENDS_INIT();
, it is output from P0.06 as follows.
count:0 count:1 count:2 count:3 count:4
If I enable both, the following error will be issued when uart_init(); is executed.
<error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at /home/nanbuwks/Downloads/Nordic/SDK/myProjects/peripheral/blinky_NRFLOGUART_printfUART/main.c:51
PC at: 0x00001443
Commenting out count: 121 count: 122 count: 123 count: 124 count: 125 I will come out. If you enable both of them, <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at /home/nanbuwks/Downloads/Nordic/SDK/myProjects/peripheral/blinky_NRFLOGUART_printfUART/main.c:51 PC at: 0x00001443 Exit with. How can I activate each one?
Environment:
- SDK 15.2.0
- SEGGER Embedded Studio Release 4.10a Build 2018110203.37618 Linux x64
- Raitac MDBT-50Q DB (nRF52840)
www.raytac.com/.../ins.php
How can I activate both at the same time?