UART interrupt

Hi nice people, I am working on developing using visual studio and Make environment. I am trying to function UART  tx/rx interrupt works but no luck. The TX and RX works perfect in blocking mode but it is not on interrupt mode. I am going to provide snippets of blocking and non blocking codes.

************************** Blocking mode *****************************************

void UART_run_blocking_test(void)
{
    nrfx_uart_config_t uart_conf = {
    .baudrate           = UART_BAUDRATE_BAUDRATE_Baud9600,
    .hwfc               = NRF_UARTE_HWFC_DISABLED,
    .parity             = NRF_UARTE_PARITY_EXCLUDED,
    .pseltxd            = UART_TX_PIN,
    .pselrxd            = UART_RX_PIN,
    .pselcts            = NRF_UART_PSEL_DISCONNECTED,
    .pselrts            = NRF_UART_PSEL_DISCONNECTED,
    .p_context          = NULL,
       
    };

    nrfx_uart_init(&uartInstance, &uart_conf, NULL);
    uint8_t txd;
    while (1)
    {
        nrfx_uart_rx(&uartInstance, &txd, 1);
        nrfx_uart_tx(&uartInstance, &txd, 1);
    }
}

************************** Non Blocking mode *****************************************

static void uart_callback (nrfx_uart_event_t const * p_event, void *p_context)
{
(void*) p_context;

switch (p_event->type)
{
case NRFX_UART_EVT_TX_DONE:

break;

case NRFX_UART_EVT_RX_DONE:
nrfx_uart_rx(&uartInstance, &txd, 1);
break;

case NRFX_UART_EVT_ERROR:

break;

default:
break;
}

}

void UART_run_non_blocking_test(void)
{
nrfx_uart_config_t uart_conf = {
.baudrate = UART_BAUDRATE_BAUDRATE_Baud9600,
.hwfc = NRF_UARTE_HWFC_DISABLED,
.parity = NRF_UARTE_PARITY_EXCLUDED,
.pseltxd = UART_TX_PIN,
.pselrxd = UART_RX_PIN,
.pselcts = NRF_UART_PSEL_DISCONNECTED,
.pselrts = NRF_UART_PSEL_DISCONNECTED,
.p_context = NULL,
.parity = NRF_UARTE_PARITY_EXCLUDED,
.interrupt_priority = NRFX_UART_DEFAULT_CONFIG_IRQ_PRIORITY,
};

nrfx_uart_init(&uartInstance, &uart_conf, uart_callback);
nrfx_uart_rx(&uartInstance, &txd, 1);
volatile uint32_t d;
while(1)
{
}
}
can u help?
Parents
  • thank you for replay edvin

    it returs nrf_succes 

    what does nrfx_uart_init() return?

    i did and the same result 

    If you want to use the non-blocking uart, I also suggest that you test the nrfx_uarte_init, instead of nrfx_uart_init()

    i followed that example 

    You can follow the definitions:


    let me add more:
    -  the code works perfect in blocking mode.
    - when transmitting, the first time it sends successfully but after that becomes busy all the time and not issuing a complete flag to trigger the interrupt 

Reply
  • thank you for replay edvin

    it returs nrf_succes 

    what does nrfx_uart_init() return?

    i did and the same result 

    If you want to use the non-blocking uart, I also suggest that you test the nrfx_uarte_init, instead of nrfx_uart_init()

    i followed that example 

    You can follow the definitions:


    let me add more:
    -  the code works perfect in blocking mode.
    - when transmitting, the first time it sends successfully but after that becomes busy all the time and not issuing a complete flag to trigger the interrupt 

Children
Related