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?
  • Edvin, it seems u didnt read my replay to your questions well.

    again:
    err_code = nrfx_uarte_init();
    or
    err_code = nrfx_uart_init();
     
    err_code becomes nrf_success

    for SDK examples i got followed the logic of this examples but i didnt use them for testing.

    i didnt use them for testing because when i have tried to compile uart examples, i got error in some libraries like putchar function ..etc.
    and i am not going to waste my time to solve compiling error for examples should run without any issue 

  • Hossam said:
    again:
    err_code = nrfx_uarte_init();
    or
    err_code = nrfx_uart_init();

    Well, your previous reply didn't say that. Not important. Thank you for clarifying.

    Hossam said:
    i didnt use them for testing because when i have tried to compile uart examples, i got error in some libraries like putchar function ..etc.
    and i am not going to waste my time to solve compiling error for examples should run without any issue 

    They should compile without errors. If they do not, it may mean that you have changed files in the SDK, and in that case it is impossible to know what your calls to nrfx_uarte_init() or nrfx_uart_init() functions do, so this could actually indicate that the SDK that you are currently using is not working properly. 

    Perhaps you can try to download an unzip a new unmodified version of the SDK, and see if:

    1: The examples compile without issues.

    2: your example works if you copy paste it into that SDK.

    You can download the SDKs from here.

    Best regards,

    Edvin

Related