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

Cannot receive UART data

I'm using the nRF52 DK with SDK 15.3.0. At this point I'm trying to get a UART loop back to work by tying the TX pin (P0.8) to the RX pin (P0.9). I have verified that the RX GPIO is set for an input and the input buffer is connected. My project is based on the "ble_app_uart" project. I see what looks like reasonable data going out on the TX pin but I never get the APP_UART_DATA_READY event in the event handler. I do get the APP_UART_TX_EMPTY event after sending the string of 4 bytes but do not get any other events. I have also tried putting a 50mS delay after sending a byte with "app_uart_put" then calling "app_uart_get" and it returns NRF_ERROR_NOT_FOUND indicating no data to read.

Looking at the UARTE0 registers after sending the data, EVENTS_RXSTARTED is a 1 and EVENTS_RXDRDY and EVENTS_ENDRX are both 0. The ENDRX interrupt is enabled, the RXD PTR is set to an address in RAM, the MAXCNT is 1 and AMOUNT is 0.

Here is my UART initialization code:

void uart_init(void)
{
    uint32_t                     err_code;
	
    app_uart_comm_params_t const comm_params =
    {
        .rx_pin_no    = PIC_TXD_BITNUM,
        .tx_pin_no    = PIC_RXD_BITNUM,
        .rts_pin_no   = 0xffffffff,									/* indicates pin isn't used */
        .cts_pin_no   = 0xffffffff,									/* indicates pin isn't used */
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
        .baud_rate    = NRF_UART_BAUDRATE_115200
    };

    APP_UART_FIFO_INIT(&comm_params,
                       UART_RX_BUF_SIZE,                            /* 256 byte buffer */
                       UART_TX_BUF_SIZE,                            /* 256 byte buffer */
                       uart_event_handler,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);
}

I get the same results with two nRF52 DK boards. Any ideas?

Parents
  • Pin P0.09 is an NFC pin and must be configured to work as an io pin before use as Rx or Tx. Add CONFIG_NFCT_PINS_AS_GPIOS in the Project->Options->Common->Preposseor->Preprocessor Definitions

    This will activate the following one-time code snippet which permanently maps P0.9 and P0.10 as GPIO - see this code in System_nrf52.c

    /

        /* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
           two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
           normal GPIOs. */
        #if defined (CONFIG_NFCT_PINS_AS_GPIOS)
            if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; // Write Enable
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; // Read-only Enable
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                // UICR changes require a reset to be effective
                NVIC_SystemReset();
            }
        #endif

    There are many posts here covering this issue if you need more background

Reply
  • Pin P0.09 is an NFC pin and must be configured to work as an io pin before use as Rx or Tx. Add CONFIG_NFCT_PINS_AS_GPIOS in the Project->Options->Common->Preposseor->Preprocessor Definitions

    This will activate the following one-time code snippet which permanently maps P0.9 and P0.10 as GPIO - see this code in System_nrf52.c

    /

        /* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined,
           two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as
           normal GPIOs. */
        #if defined (CONFIG_NFCT_PINS_AS_GPIOS)
            if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; // Write Enable
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; // Read-only Enable
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                // UICR changes require a reset to be effective
                NVIC_SystemReset();
            }
        #endif

    There are many posts here covering this issue if you need more background

Children
No Data
Related