This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART interrupt doesn't occur for subsequent receptions

I am writing my own UART driver and having trouble getting subsequent interrupts. The first time I see the interrupt occurs but nothing after.

According to the product spec, RXDRDY event register should be cleared before RXD register is read.

That's what I'm doing inside the IRQ handler though the interrupt only happens once.

void UARTE0_UART0_IRQHandler(void)
    {        
        bool isDataReceived = pInstance->getNrfEventStatus(NRF_UART_EVENT_RXDRDY);
        bool rxIrqEnabled = pInstance->getNrfRegStatus(UARTx->INTENSET, NRF_UART_INT_MASK_RXDRDY);
        bool rxToIrqEnabled = pInstance->getNrfEventStatus(NRF_UART_INT_MASK_RXTO);
    
        if (rxIrqEnabled && isDataReceived)
        {
	        pInstance->setNrfEvent(NRF_UART_EVENT_RXDRDY, DISABLE); // disable event
	        uint32_t dataRxd = UARTx->RXD;    // read RXD register
	        pFifoRx->enque(dataRxd);    // write to FIFO
        }
        // ...
    }

Parents
  • Hi,

    You have a form of HAL here which I have no knowledge about (setNrfEvent()) etc. Pleas show all code that is not from Nordic. I do not see anything here that would explain why you get no new interrupts, but also I do not know exactly what I am looking at.

  • On the off chance DISABLE is not writing '0' (as inferred by Einor) maybe replace the line:

    Nordic usage:
      nrf_uart_event_clear(p_uart, NRF_UART_EVENT_RXDRDY);
    
    ie a '0' is written to NRF_UART_EVENT_RXDRDY
    
    Try changing
      pInstance->setNrfEvent(NRF_UART_EVENT_RXDRDY, DISABLE); // disable event
    to
      pInstance->clrNrfEvent(NRF_UART_EVENT_RXDRDY);    // cancel event
    or
      pInstance->setNrfEvent(NRF_UART_EVENT_RXDRDY, 0); // cancel event

    I suggest this since to "disable" or set some registers to '0' a '1' must be written to an associated "CLR" register; although that is not the case here maybe DISABLE is writing a '1' which may give the issue you describe

Reply
  • On the off chance DISABLE is not writing '0' (as inferred by Einor) maybe replace the line:

    Nordic usage:
      nrf_uart_event_clear(p_uart, NRF_UART_EVENT_RXDRDY);
    
    ie a '0' is written to NRF_UART_EVENT_RXDRDY
    
    Try changing
      pInstance->setNrfEvent(NRF_UART_EVENT_RXDRDY, DISABLE); // disable event
    to
      pInstance->clrNrfEvent(NRF_UART_EVENT_RXDRDY);    // cancel event
    or
      pInstance->setNrfEvent(NRF_UART_EVENT_RXDRDY, 0); // cancel event

    I suggest this since to "disable" or set some registers to '0' a '1' must be written to an associated "CLR" register; although that is not the case here maybe DISABLE is writing a '1' which may give the issue you describe

Children
Related