Hi everyone,
I am trying to use the nrfx_uarte driver. I did the following:
(a) setup driver
nrfx_uarte_config_t uarte_config = { .pseltxd = RX_PIN_NUMBER, .pselrxd = TX_PIN_NUMBER, .pselcts = CTS_PIN_NUMBER, .pselrts = RTS_PIN_NUMBER, .p_context = NULL, .hwfc = NRF_UARTE_HWFC_DISABLED, .parity = NRF_UARTE_PARITY_EXCLUDED, .baudrate = NRF_UARTE_BAUDRATE_115200, .interrupt_priority = 2 }; APP_ERROR_CHECK(nrfx_uarte_init(&uarte, &uarte_config, uarte_event_handler));
(b) setup the event handler
static void uarte_event_handler(nrfx_uarte_event_t const *p_event, void *p_context)
{
static uint8_t step = 0;
static uint8_t stopCount = 0;
if (p_event->type == NRFX_UARTE_EVT_TX_DONE)
{
tx_done = true;
rx_done = false;
rx_count = 0;
nrfx_err_t error = nrfx_uarte_tx(&uarte, "Hello", 5);
NRF_LOG_INFO("Data Sent");
}
if (p_event->type == NRFX_UARTE_EVT_RX_DONE)
{
uint8_t inbyte = 0;
if (p_event->data.rxtx.bytes > 0)
{
inbyte = *p_event->data.rxtx.p_data;
if ((inbyte != ' ') && (inbyte != '\0'))
{
char inbuffer[2] = {inbyte, '\0'};
strcat(rx_buffer, inbuffer);
if ((strstr(rx_buffer, "OK\r\n") != NULL) || (strstr(rx_buffer, "ERROR\r\n") != NULL))
{
rx_done = true;
NRF_LOG_INFO("Data Received");
NRF_LOG_PUSH(rx_buffer);
//NRF_LOG_HEXDUMP_INFO(rx_buffer, rx_count);
}
}
nrfx_uarte_rx(&uarte, m_int_buffer, 1);
}
}
if (p_event->type == NRFX_UARTE_EVT_ERROR)
{
trfx_error = true;
NRF_LOG_INFO("Error Occured");
APP_ERROR_CHECK(p_event->data.error.error_mask);
}
}
(c) finally tried to send some testing data
nrfx_err_t error = nrfx_uarte_tx(&uarte, "Hello", 5);
I don't get any error but I don't get any data either.
I put to lines that set/reset TX pin inside a while(true) loop and I got a square wave of ~330KHz on the oscilloscope, so I assume that the physical pin in terms of hardware is fully functioning.
Am I missing something? Please any advice is more than welcome.
Best regards,
Stavros Makridis.