I am having trouble because TX / RX processing using UARTE cannot be performed.
nrf52840 DK <---------> PC
The operation of TX / RX can be confirmed with UART. (Interrupts can be fetched)
But I can't do TX / RX with UARTE (Easy DMA).
I will show you the code, please tell me how to use it correctly.
/** * uart_driver.c **/ #define UART_PORT0_TX_PIN NRF_GPIO_PIN_MAP(1, 1) #define UART_PORT0_RX_PIN NRF_GPIO_PIN_MAP(1, 2) static nrfx_uarte_t uarte_instance_0 = NRFX_UARTE_INSTANCE(UART_PORT0_INSTANCE); static uint8_t readerBuffer[UART_TX_BUFFER_SIZE] __attribute__((section(".ram_uarte1_rx"))) = { 0 }; // Data RAM static uint8_t writerBuffer[UART_TX_BUFFER_SIZE] __attribute__((section(".ram_uarte1_tx"))) = { 0 }; // Data RAM static void uart_port0_event_handler(nrf_drv_uart_event_t* p_event, void* p_context) { switch (p_event->type) { case NRF_DRV_UART_EVT_TX_DONE: break; case NRF_DRV_UART_EVT_RX_DONE: NRF_LOG_HEXDUMP_DEBUG(p_event->data.rxtx.p_data, p_event->data.rxtx.bytes); break; case NRF_DRV_UART_EVT_ERROR: break; } } void uart_driver_init(void) { ret_code_t err_code; nrfx_uarte_config_t nrfx_uarte_config0; // Nordic SDKのUART設定構造体 nrfx_uarte_config0.baudrate = NRF_UART_BAUDRATE_9600; nrfx_uarte_config0.hwfc = NRF_UART_HWFC_DISABLED; nrfx_uarte_config0.interrupt_priority = 2; nrfx_uarte_config0.parity = NRF_UART_PARITY_EXCLUDED; nrfx_uarte_config0.pselcts = NRF_UART_PSEL_DISCONNECTED; nrfx_uarte_config0.pselrts = NRF_UART_PSEL_DISCONNECTED; nrfx_uarte_config0.pselrxd = UART_PORT0_TX_PIN; nrfx_uarte_config0.pseltxd = UART_PORT0_RX_PIN; err_code = nrfx_uarte_init(&uarte_instance_0, &nrfx_uarte_config0, uarte_port0_event_handler); } uart_driver_send_data(void) { ret_code_t err_code; char data[] = "hello!!"; memset(writerBuffer, 0x00, sizeof(writerBuffer)); memcpy(writerBuffer,data, 7); err_code = nrfx_uarte_tx(&uarte_instance_0, writerBuffer, send_data_len); } void uart_read(void){ nrfx_uarte_rx(&uarte_instance_0, readerBuffer, 6); } /** * main.c **/ APP_TIMER_DEF(uart_test_timer_id); static void uart_timer_handler(void* p_context) { uart_driver_send_data(); uart_read(); } int main(void) { APP_ERROR_CHECK(nrf_sdh_enable_request()); log_init(); power_management_init(); ret_code_t err_code = app_timer_init(); APP_ERROR_CHECK(err_code); app_timer_create(&uart_test_timer_id, APP_TIMER_MODE_REPEATED, uart_timer_handler); uart_driver_init(); app_timer_start(uart_test_timer_id, APP_TIMER_TICKS(5000), NULL); while (true) { idle_state_handle(); } }