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

nRF52810 uart RX issue

Hi team, I faced the following problem: there is a custom board with nRF52810 on it, UART is used on this board.

I set up Debug configuration and UART is working OK, but when I switched to Release config UART is not working properly (there is no UART RX interrupt). I managed to figure out what is wrong. In order to INIT UART (one of the settings) you have to specify RX buffer length. So, in Debug config after init function settings are correct and UART RX buffer length keeps its value and the state is INITIALIZED. If I switch to Release config UART RX buffer length is 0 and the state is UNINITIALIZED. I tried to change different combination of optimization level, but nothing works. How to solve the problem and why it happens?
IDE: Segger Studio.

Parents Reply Children
  • Hi, here is my inti function for UART

    static uint8_t m_tx_buffer[1] = { 0 };
    static uint8_t m_rx_buffer[1] = { 0 };
    
    uart_status_t uart_init(uart_t uart, port_t portTx, pin_t pinTx, port_t portRx, pin_t pinRx, hwfc_t flow, parity_t parity, baud_rate_t baud){
    //static nrf_drv_uart_t l_uart = NRF_DRV_UART_INSTANCE(0);
    //memcpy(&m_uart, &l_uart, sizeof(m_uart));
    
    nrf_drv_uart_config_t l_uart_cfg = NRF_DRV_UART_DEFAULT_CONFIG;
    uint32_t l_pin_rx_map = NRF_UART_PSEL_DISCONNECTED;
    uint32_t l_pin_tx_map = NRF_UART_PSEL_DISCONNECTED;
    uint32_t l_pin_cts_map = NRF_UART_PSEL_DISCONNECTED;
    uint32_t l_pin_rts_map = NRF_UART_PSEL_DISCONNECTED;
    nrf_uart_hwfc_t l_flow = NRF_UART_HWFC_DISABLED;
    nrf_uart_parity_t l_parity = NRF_UART_PARITY_EXCLUDED;
    nrf_uart_baudrate_t l_baud = NRF_UART_BAUDRATE_115200;
    
    l_pin_tx_map = NRF_GPIO_PIN_MAP(portTx, pinTx);
    l_pin_rx_map = NRF_GPIO_PIN_MAP(portRx, pinRx);
    
    if(flow == ENABLE){
    l_flow = NRF_UART_HWFC_ENABLED;
    }
    
    if(parity == INCLUDE){
    l_parity = NRF_UART_PARITY_INCLUDED;
    }
    
    switch(baud){
    case BAUD_1200:
    l_baud = NRF_UART_BAUDRATE_1200;
    break;
    case BAUD_2400:
    l_baud = NRF_UART_BAUDRATE_2400;
    break;
    case BAUD_4800:
    l_baud = NRF_UART_BAUDRATE_4800;
    break;
    case BAUD_9600:
    l_baud = NRF_UART_BAUDRATE_9600;
    break;
    case BAUD_19200:
    l_baud = NRF_UART_BAUDRATE_19200;
    break;
    case BAUD_38400:
    l_baud = NRF_UART_BAUDRATE_38400;
    break;
    case BAUD_57600:
    l_baud = NRF_UART_BAUDRATE_57600;
    break;
    case BAUD_115200:
    l_baud = NRF_UART_BAUDRATE_115200;
    break;
    }
    
    l_uart_cfg.interrupt_priority = UART_DEFAULT_CONFIG_IRQ_PRIORITY;
    l_uart_cfg.use_easy_dma = true;
    
    l_uart_cfg.pseltxd = l_pin_tx_map;
    l_uart_cfg.pselrxd = l_pin_rx_map;
    l_uart_cfg.hwfc = l_flow;
    l_uart_cfg.parity = NRF_UART_PARITY_INCLUDED;
    l_uart_cfg.baudrate = l_baud;
    
    nrf_drv_uart_init(&m_uart, &l_uart_cfg, uart_handler);
    
    fifo_init(&m_fifo, FIFO_SIZE);
    ring_init(&m_ring, RING_SIZE);
    
    m_uart_init_state = true;
    
    
    ret = nrf_drv_uart_rx(&m_uart, m_rx_buffer, 1);
    
    if(ret != NRF_SUCCESS){
    ERROR_HANDLER();
    }
    return UART_OK;
    }

  • The biggest misunderstanding for me is that the similar code works fine on nRF52840. I just port the same code from nRF52840 to nRF52810. It seems to me that there is should not be difference between UART init function for 840 and 810.

Related