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

UART break not working

Hello, we can't seem to be UART break working in interrupt. Is there any detailed documentation on UART operation? We're using the spi_mem_nRF51 Series Reference Manual Version 2.1. It works for TDX and RDX but not an error. Below is our setup and interrupt code. Thanks

void uart_init(void) {

simple_uart_config(RTS_PIN_NUMBER, TX_PIN_NUMBER, CTS_PIN_NUMBER, RX_PIN_NUMBER, HWFC);

// Enable interrupt:
NVIC_EnableIRQ(UART0_IRQn);
NRF_UART0->INTENSET  = (UART_INTENSET_RXDRDY_Set << UART_INTENSET_RXDRDY_Pos) | 
    (UART_INTENSET_TXDRDY_Set << UART_INTENSET_TXDRDY_Pos) |
        (UART_INTENSET_ERROR_Set << UART_INTENSET_ERROR_Pos);

}

void UART0_IRQHandler(void) {

// RX data in interrupt
if (NRF_UART0->EVENTS_RXDRDY == 1)
{
    NRF_UART0->EVENTS_RXDRDY = 0;
    
    uart_state_m(UART_EVENT_RX, NRF_UART0->RXD);
        
}
    // TX data in interrupt
if (NRF_UART0->EVENTS_TXDRDY == 1)
{
    NRF_UART0->EVENTS_TXDRDY = 0;
    
    uart_state_m(UART_EVENT_TX, 0);
        
}
    // RX data in interrupt
if (NRF_UART0->EVENTS_ERROR == 1)
{
    NRF_UART0->EVENTS_ERROR = 0;
    
    uart_state_m(UART_EVENT_ERROR, NRF_UART0->ERRORSRC);
        
}

}

  • I'm not sure what your issue is. I added your code to the default uart_example in the nRF51SDK and the interrupts fires as expected. You say that RXD and TXD works, but not an error? What do you mean by this? Are you getting data through on the UART or are you seeing some issues sending/transmitting? Do you not see the interrupts firing?

    EDIT: It will be seen as a FRAMING error first of all, but the BREAK error is still available as a source too. Please have a look at the attached code example that prints the error codes.UART INT example v1.2mod.zip

  • Basically if I issue a break sequence on my terminal (into the UART) I don't get an error interrupt. The documentation is not very detailed but I assume that break is one of the UART0 errors (well its in ERRORSRC register in System viewer). I DO get an interrupt on RX and TX data though. Thanks

  • Edited my answer with information about the error source and code example. It sounds like the error is there, but it will most likely show up as a framing error as well. Have a look at the code example.