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

Communication between nrf52840 and nrf9160 on thingy 91

Hei

I am trying to make SPI or UART communication between nrf9160 and nrf52840 on thingy 91....... i need to send data from nrf52840 to nrf9160(i will use and print the data)
what is the best way to do it? I tried connectivity bridge, but with no hope......


Another small question....i cannot get any thing out on putty when i write printk("hello world"); in the main function in connectivity bridge code ...how to fix it?

Parents
  • Hello Mohammad,

    you can communicate between the nRF9160 and nRF52840 on the Thingy:91 using MCU_IF.

    https://www.nordicsemi.com/-/media/Software-and-other-downloads/Dev-Kits/Thingy91/Hardware-files/Thingy91---Hardware-files-1_5_0.zip

    Have a look at “PCA20035_Schematic_And_PCB.pdf” page 2 (nRF91 GPIO pin mapping) & 3 (nRF52 GPIO pin mapping). The instances UART0 and UART1 on both sides are already pre-configured to communicate with each other.

     

    Another small question....i cannot get any thing out on putty when i write printk("hello world"); in the main function in connectivity bridge code ...how to fix it?

    In the file ../build/zephyr/zephyr.dts you can see that UART0 is used to write to the console. But since the connectivity bridge application doesn’t have a “connectivity bridge” for its own console data, it will not be transmitted from the nRF52840 via USB. Alternatively, you can use RTT to read printk commandos by setting CONFIG_RTT_CONSOLE=y in prj.conf.

     Cheers!

    Markus

  • hei
    Thanks for your answer

    1-
    I see that i can use MCU_IF to communicate between nrf91 and nrf52840, and I road that the connectivity bridge has already done it (if i don't misunderstand it) ....but how/ where I will write my code? do you have an example for UART functions? write and read? all I need for now is to send one string between nrf91 and nrf52840 and print it out to putty 

    I am using the connectivity bridge on nrf52840 and the asset tracker on nrf9160

    2-
    I tried CONFIG_RTT_CONSOLE=y on my prj.conf but i still don't get any output, is there anything else i can enable/disable to fix it?

Reply
  • hei
    Thanks for your answer

    1-
    I see that i can use MCU_IF to communicate between nrf91 and nrf52840, and I road that the connectivity bridge has already done it (if i don't misunderstand it) ....but how/ where I will write my code? do you have an example for UART functions? write and read? all I need for now is to send one string between nrf91 and nrf52840 and print it out to putty 

    I am using the connectivity bridge on nrf52840 and the asset tracker on nrf9160

    2-
    I tried CONFIG_RTT_CONSOLE=y on my prj.conf but i still don't get any output, is there anything else i can enable/disable to fix it?

Children
  • Thanks for your answer 
    now i dont get the same feil when i use uart0_dev = device_get_binding("UART_0");

    but i get another feil (Failed to set callback) 


    the code is:

    static void async(const struct device *uart0_dev)
    {
    uint8_t txbuf[5] = {1, 2, 3, 4, 5};
    int err;
    uint8_t *buf;

    err = k_mem_slab_alloc(&uart_slab, (void **)&buf, K_NO_WAIT);
    __ASSERT(err == 0, "Failed to alloc slab");

    err = uart_callback_set(uart0_dev, uart_callback, (void *)uart0_dev);
    __ASSERT(err == 0, "Failed to set callback");  

    err = uart_rx_enable(uart0_dev, buf, BUF_SIZE, 10);
    __ASSERT(err == 0, "Failed to enable RX");

    while (1) {
    err = uart_tx(uart0_dev, txbuf, sizeof(txbuf), 10);
    __ASSERT(err == 0, "Failed to initiate transmission");

    k_sleep(K_MSEC(500));

    uart_poll_out(uart0_dev, txbuf[0]);
    k_sleep(K_MSEC(100));
    }
    }


    main function:

    void main(void)
    {
    LOG_INF("Asset tracker started");


    const struct device *uart0_dev;

    k_msleep(1000);
    uart0_dev = device_get_binding("UART_0");
    //lpuart = device_get_binding("LPUART");
    __ASSERT(uart0_dev, "Failed to get the device");

    if (IS_ENABLED(CONFIG_NRF_SW_LPUART_INT_DRIVEN)) {
    interrupt_driven(uart0_dev);
    } else {
    async(uart0_dev);
    }


    I think the feil is from my overlay file:

    overlay file:

    &uart0 {
    compatible = "nordic,nrf-uarte";
    status = "okay";
    rx-pin = <19>;
    tx-pin = <20>;
    baudrate = <1000000>;
    /delete-property/ rts-pin;
    /delete-property/ cts-pin;
    /delete-property/ hw-flow-control;
    };


    prj.conf:

    i added to the original prj file

    CONFIG_UART_ASYNC_API=y

    thanks for your help 

    Mohammad





Related