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

UART Communication between nrf52840 and nrf9160 on nrf9160 dk

Hello,

We have an nrf9160 dk-pca10090 board.

We want to know if there is a way to make the two processors (nrf52840 and nrf9160) communicate using uart.

Kindly point us to a sample uart program to achieve this.

Thanks

Regards

  • I was able to adapt the uart_pipe code (in ncs v1.2 at ./zephyr/drivers/console/uart_pipe.c) with the following changes for the 9160 image:

    prj.conf:
    CONFIG_UART_PIPE=y
    CONFIG_UART_PIPE_ON_DEV_NAME="UART_2"
    CONFIG_UART_CONSOLE_LOG_LEVEL_INF=y
    ### configure the uart between 9160 and 52840
    CONFIG_UART_2_NRF_UARTE=y
    CONFIG_UART_2_NRF_FLOW_CONTROL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y

    child_secure_partition_manager.conf:
    CONFIG_SPM_NRF_UARTE2_NS=y

    nrf9160_pca10090ns.overlay:
    / {
    chosen {
    zephyr,bt-uart=&uart2;
    };
    };

    &uart2 {
    current-speed = <1000000>;
    status = "okay";
    tx-pin = <18>;
    rx-pin = <17>;
    rts-pin = <21>;
    cts-pin = <19>;
    };

    And for building the image for the nrf52840:

    prj.conf:
    CONFIG_UART_PIPE=y
    CONFIG_UART_PIPE_ON_DEV_NAME="UART_1"
    CONFIG_UART_CONSOLE_LOG_LEVEL_INF=y
    CONFIG_UART_1_NRF_UARTE=y
    CONFIG_UART_1_NRF_FLOW_CONTROL=y

    nrf52840_pca10090.overlay:
    / {
    chosen {
    zephyr,uart-pipe=&uart1;
    };
    };

    &uart1 {
    compatible = "nordic,nrf-uarte";
    current-speed = <1000000>;
    status = "okay";
    tx-pin = <17>;
    rx-pin = <20>;
    rts-pin = <15>;
    cts-pin = <22>;
    };

  • Hello,

    We have applied the above, we wrote the code below;

    On 52840

    #include <zephyr.h>
    #include <misc/printk.h>
    #include <uart.h>
    #include <drivers/console/uart_pipe.h>
    
    
    static u8_t uart_buf[1024];
    static struct device *uart_pipe_dev;
    int count = 0;
    
    uart_pipe_recv_cb uart_cb(u8_t *buf, size_t *off){
      printk("received data on 52");
      return (uart_pipe_recv_cb)uart_buf;
    }
    
    
    void main(void)
    {
            printk("Started application uart send and read on 52 \n");
           uart_pipe_register(uart_buf,sizeof(uart_buf),uart_cb);
            while (1) {
                count++;
                u8_t* data = &count;            
                int sent = uart_pipe_send(data,sizeof(data));
                if(sent>-1){
                  printk("sent data %d, with size %d \n", count,sizeof(data));
                }else{
                  printk("Could not send data \n");
                }
                k_sleep(2000);
    	}
    }
    

    On 9160

    #include <zephyr.h>
    #include <misc/printk.h>
    #include <uart.h>
    #include <drivers/console/uart_pipe.h>
    
    
    static u8_t uart_buf[1024];
    static struct device *uart_pipe_dev;
    int count = 0;
    
    
    uart_pipe_recv_cb uart_cb(u8_t *buf, size_t *off){ 
      printk("received \n");
      
      return buf;
    }
    
    
    void main(void)
    {
            printk("Started application uart send and read on 91 \n");
           u8_t uart_buf_init;
           uart_pipe_register(&uart_buf_init,sizeof(uart_buf_init),uart_cb);
            while (1) {
                count = count + 1;
                u8_t* data = &count;            
                int sent = uart_pipe_send(data,sizeof(data));
                if(sent>-1){
                  printk("sent data %d, with size %d \n", count,sizeof(data));
                }else{
                  printk("Could not send data \n");
                }
                k_sleep(2000);
    	}
    }
    

    however we do not have any communication between 9160 and 52840, specifically from 52840 to 9160.

    The only thing we had was a loopback on 9160 when we put a cable from pin P0.17 to P0.18. Could you please share sample code or what specifically we have to do to get this done.

    Thanks and Regards

  • Hi,

    smauelGIS said:
    however we do not have any communication between 9160 and 52840, specifically from 52840 to 9160.

    Try setting 

    CONFIG_BOARD_PCA10090_INTERFACE0_MCU=y
    CONFIG_BOARD_PCA10090_INTERFACE1_MCU=y
    in the nRF52840 project. See this link.
Related