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

BLE demo with UART not working

Hi there,

I was able to successfully compile and run the "BLE HIDS keyboard" example on my nRF52832 using Segger SES 5.44

My Nordic chip is connected via UART Rx/Tx to another MSP430 and I like to send some data bytes from the MSP to the Nordic chip. So I checked the various UART examples in the nRF5 SDK 17.0.2 (which we want to use) and added some Uart code to the HIDS keyboard example. My hardware is similar to pca10040, but its not identical. I also have a Led connected to Port P0.17 so I can see the blinking code while BLE advertising is active etc

Withoutn Uart code , the Nordic chip starts, I can see the Led blinking and then the device is advertising and I can connect my smartphone - for diagnostics I'm using the "nRF connect" app which works well.

With Uart, my main() routine includes a call to a uart_init() routine which basically calls APP_UART_FIFO_INIT() - without this call, the Nordic chip works well as explained above, when calling this APP_UART_FIFO_INIT(), the Led goes solid on and I'm not able to connect to the device in any way.

Comm Params are like this

static void uart_init(void)
{
    uint32_t  err_code;
    app_uart_comm_params_t const comm_params =
    {
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
        .baud_rate    = NRF_UART_BAUDRATE_57600
    };

    if (1)
    {
      APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_event_handle,
                         APP_IRQ_PRIORITY_HIGH,
                         err_code);
    }
}

I checked, as good as possible, the settings in sdk_config.h but I can't find out why the device is not working with Uart.

Any idea what might be missing ?

thanks, Matthias

Parents
  • I build with Debug and I also switched to another Hardware board (UTO-NBL-42a) - its a small breakout board - to eliminate any possible issue with the MSP430

    Without "uart_init" the debug terminal output is like this, just fine

    Starting..
    <info> app_timer: RTC: initialized.
    <info> app:     m_whitelist_peer_cnt 2, MAX_PEERS_WLIST 8
    <info> app: Fast advertising with whitelist.
    <info> app: Slow advertising with whitelist.

    With "uart_init" is see this

    Starting..
    UartInit
    <info> app_timer: RTC: initialized.
    <info> app_timer: RTC: initialized.
    <info> app:     m_whitelist_peer_cnt 2, MAX_PEERS_WLIST 8
    <info> app: Fast advertising with whitelist.
    <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at F:\Keil\nRF5_SDK_17.0.2_d674dde\components\libraries\timer\app_timer2.c:181
    PC at: 0x00028427

    After the first "RTC initialized" it takes approx 20 secs, then I see the 2nd "RTC initialised" and the error in app_error_fault_handler() with ID=0x4001

    APP_UART_FIFO_INIT returns =8, but according to some other posts, I assume this is ok

    I added a 10 kOhm resistor to Uart RX (P0.08) but see no change either.

  • sorry - I meant show us the C source code.

  • its only this line  : 181 : APP_ERROR_CHECK(err_code);
    the file app_timer2.c is the original from the SDK

  • I tried in the meanwhile the ble_app_uart example - I can connect over BLE, but see no data. I'm using a CP2102 serial USB chip to connect to my windows PC as virtual COM7 with putty.

    From the defines in pca10040.h : RxD is set to RX_PIN_NUMBER = 8, so this is P0.08, right ?
    and TX pin number is 6, so P0.06, right ?
    I assume its correct to cross connect Nordic:RxD <> CP2102:TxD and Nordic TxD <> CP2102 RxD ?
    Is it necessary to wire RTS/CTS in any way ?

  • its only this line  : 181 : APP_ERROR_CHECK(err_code);

    Well, of course it is - that's the line that catches & throws the error 

    What you need to look at is the lines immediately before that - what is it which gives that error_code ?

    And then look-up that function's documentation - that will tell you the reasons why it might return an error code of 4.

  • RxD is set to RX_PIN_NUMBER = 8, so this is P0.08, right ?
    and TX pin number is 6, so P0.06, right ?

    Yes.

    I assume its correct to cross connect Nordic:RxD <> CP2102:TxD and Nordic TxD <> CP2102 RxD ?

    Almost certainly, but check the datasheets:

    • The UART output from the nRF needs to go to the UART input of the CP2102;
    • The UART input to the nRF needs to come from to the UART output of the CP2102.
    Is it necessary to wire RTS/CTS in any way

    It depends:

    1. does your code implement flow control?
    2. does whatever's connected to the CP2102 require flow control?
Reply
  • RxD is set to RX_PIN_NUMBER = 8, so this is P0.08, right ?
    and TX pin number is 6, so P0.06, right ?

    Yes.

    I assume its correct to cross connect Nordic:RxD <> CP2102:TxD and Nordic TxD <> CP2102 RxD ?

    Almost certainly, but check the datasheets:

    • The UART output from the nRF needs to go to the UART input of the CP2102;
    • The UART input to the nRF needs to come from to the UART output of the CP2102.
    Is it necessary to wire RTS/CTS in any way

    It depends:

    1. does your code implement flow control?
    2. does whatever's connected to the CP2102 require flow control?
Children
No Data
Related