I am implementing nrfx uarte on nRF52840 with ncs 2.6.1. I am using the example provided in modules\hal\nordic\nrfx\samples\src\nrfx_uarte as a reference.
Reason for using nrfx instead of zephyr API is the ability to change UART TX and RX pins during runtime. Because my design contains 3 UART devices. I am sure that there is only one line calling IRQ_CONNECT and I have tried clean build configuration and rebuild but the problem persist. If I comment out IRQ_CONNECT function, the code build without error but nothing is shown in the console log if I run the code.
I have found only 1 similar thread said that config CONFIG_NRFX_I2S0=y and CONFIG_I2S_NRFX=n to avoid this problem( IRQ_CONNECT duplication causing gen_isr_tables.py to fail). But CONFIG_UARTE1_NRFX does not exist.
main.c
#include <nrfx_uarte.h>
#include <zephyr/irq.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(nrfx_sample, LOG_LEVEL_INF);
#define UARTE_INST_IDX 1
#define UARTE_TX_PIN 31
#define UARTE_RX_PIN 30
static uint8_t m_tx_buffer[] = {0x01, 0x03, 0x01, 0x00, 0x00, 0x01, 0x85, 0xF6};
static uint8_t m_rx_buffer[sizeof(m_tx_buffer)];
/**
* @brief Function for handling UARTE driver events.
*
* @param[in] p_event Pointer to event structure. Event is allocated on the stack so it is available
* only within the context of the event handler.
* @param[in] p_context Context passed to the interrupt handler, set on initialization. In this example
* p_context is used to pass the address of the UARTE instance that calls this handler.
*/
static void uarte_handler(nrfx_uarte_event_t const * p_event, void * p_context)
{
nrfx_uarte_t * p_inst = p_context;
if (p_event->type == NRFX_UARTE_EVT_TX_DONE)
{
LOG_INF("--> UARTE event: TX done");
LOG_INF("Content of TX buffer: %s", m_tx_buffer);
LOG_INF("Content of RX buffer: %s", m_rx_buffer);
}
else
{
LOG_INF("UARTE event: %d", p_event->type);
}
nrfx_uarte_uninit(p_inst);
}
int main(void)
{
nrfx_err_t status;
(void)status;
#if defined(__ZEPHYR__)
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_UARTE_INST_GET(UARTE_INST_IDX)), IRQ_PRIO_LOWEST,
NRFX_UARTE_INST_HANDLER_GET(UARTE_INST_IDX), 0, 0);
#endif
LOG_INF("Starting nrfx_uarte non-blocking example.");
nrfx_uarte_t uarte_inst = NRFX_UARTE_INSTANCE(UARTE_INST_IDX);
nrfx_uarte_config_t uarte_config = NRFX_UARTE_DEFAULT_CONFIG(UARTE_TX_PIN, UARTE_RX_PIN);
uarte_config.p_context = &uarte_inst;
status = nrfx_uarte_init(&uarte_inst, &uarte_config, uarte_handler);
NRFX_ASSERT(status == NRFX_SUCCESS);
LOG_INF("Content of TX buffer: %s", m_tx_buffer);
LOG_INF("Content of RX buffer: %s", m_rx_buffer);
status = nrfx_uarte_rx(&uarte_inst, m_rx_buffer, sizeof(m_rx_buffer));
NRFX_ASSERT(status == NRFX_SUCCESS);
status = nrfx_uarte_tx(&uarte_inst, m_tx_buffer, sizeof(m_tx_buffer), 0);
NRFX_ASSERT(status == NRFX_SUCCESS);
while (1)
{
}
}
Error message
gen_isr_tables.py: error: multiple registrations at table_index 40 for irq 40 (0x28) Existing handler 0x6295, new handler 0x9eb1 Has IRQ_CONNECT or IRQ_DIRECT_CONNECT accidentally been invoked on the same irq multiple times?
I'd appreciate any help or advice you can offer. Thanks in advance!