This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Why simple_uart can't work in ble project?

My board is nrf51822. Simple_uart works fine in uart_example, but once I copy it to my ble project which can work, it stuck. Part of my code :

advertising_init();
services_init();
conn_params_init();
sec_params_init();

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

	simple_uart_putstring((const uint8_t *)" \n\rStart: ");
while(true)
{
    uint8_t cr = simple_uart_get();
    simple_uart_put(cr);

    if(cr == 'q' || cr == 'Q')
    {
        while(true)
        {
            // Do nothing.
        }
    }
}

// Enter main loop.
for (;;)
{
    power_manage();
}

Problem in a while loop for waiting uart ready:

while (NRF_UART0->EVENTS_TXDRDY!=1)

Same code in uart_example, it works fine, but in my ble project or a ble example, none of rx and tx can be done.

  • Can you check that the macros used in simple_uart_config expand to the same values in the uart_example and your BLE project? If the UART pins on the nRF51822 are not connected to something that receives, hardware flow control will make your code stuck waiting for EVENTS_TXDRDY.

  • I set the right pin number to uart_config(19, 17, 18, 16, false) , it received wrong pin number parameters :13, AB, 0, F7. So I set registers to right pin directly, like NRF_UART0->PSELTXD = 17; NRF_UART0->PSELRXD = 16;. But it didn't work.

Related