Hello,
I am using the serial output logging (via UART) via the following calls/macros:
NRF_LOG_DEBUG("test");
Now I want to get also serial input (data from PC to uC), so I can execute some test patterns by keypress on PC (only under certain circumstances, but does not matter):
How can I get input data?
As far as I have seen, the UART in initialized in
nrf_drv_uart_init in file nRF5_SDK_17.0.2_d674dde\integration\nrfx\legacy\nrf_drv_uart.c
via
uart_init in file nRF5_SDK_17.0.2_d674dde\components\libraries\log\src\nrf_log_backend_uart.c
In nrf_log_backend_uart.c I have added for test purposes:
static void uart_evt_handler(nrf_drv_uart_event_t * p_event, void * p_context)
{
if(p_event->type == NRF_DRV_UART_EVT_TX_DONE) ///< Requested TX transfer completed.
{
// No debug output here, perhaps endless loop in outputting?
}
else if(p_event->type == NRF_DRV_UART_EVT_RX_DONE) ///< Requested RX transfer completed.
{
NRF_LOG_INFO("Key");
}
else if(p_event->type == NRF_DRV_UART_EVT_ERROR) ///< Error reported by UART peripheral.
{
NRF_LOG_INFO("Error");
}
m_xfer_done = true;
}
NRF_LOG_DEFERRED is set to 1, so async_mode is true and I assume the event handler is used.
But I don't get any input.
I already tried
nrf_drv_uart_rx_enable(&m_uart);
in uart_init, but no change, still not working.
I looked at the INTEN of UART like
{
// nrf_drv_uart_rx_enable(&m_uart);
uint8_t data[8];
uint8_t anz;
extern nrf_drv_uart_t const m_uart;
anz = nrf_drv_uart_rx(&m_uart, &data, 8);
NRF_LOG_DEBUG("NrOfReceivedBytes=%d", anz);
uint32_t enable = NRF_UART0->ENABLE;
NRF_LOG_DEBUG("enable=%08lx", enable);
uint32_t pseltxd = NRF_UART0->PSELTXD;
NRF_LOG_DEBUG("pseltxd=%08lx", pseltxd);
uint32_t pselrxd = NRF_UART0->PSELRXD;
NRF_LOG_DEBUG("pselrxd=%08lx", pselrxd);
uint32_t txstarted = NRF_UARTE0->EVENTS_TXSTARTED;
NRF_LOG_DEBUG("txstarted=%08lx", txstarted);
uint32_t rxstarted = NRF_UARTE0->EVENTS_RXSTARTED;
NRF_LOG_DEBUG("rxstarted=%08lx", rxstarted);
uint32_t inten = NRF_UARTE0->INTEN;
NRF_LOG_DEBUG("inten=%08lx", inten);
}
It displays:
[00:00:29.000,000] <debug> app: NrOfReceivedBytes=0
[00:00:29.000,000] <debug> app: enable=00000008
[00:00:29.000,000] <debug> app: pseltxd=00000007
[00:00:29.000,000] <debug> app: pselrxd=00000008
[00:00:29.000,000] <debug> app: txstarted=00000001
[00:00:29.000,000] <debug> app: rxstarted=00000001
[00:00:29.000,000] <debug> app: inten=00420310
Looking at set bits in inten, I would say, receiving is enabled?
What else do I need/can I check? I have used UART(E) in UART mode, without logging, and get input,
so I assume hardware/connection is at least working, this should be no problem.
Many thanks!
Best regards,
Marie