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

nRF9160 DK GPIO-UART

Dear, 

I am using nRF9160 DK, I want to use nRF9160 SIP to connect with another sensor ( UART /SPI) 

Do you have any suggestions or examples?

Thanks,

Rgards

hng

  • Hi,

     

    In the "uart" sample, UARTE0 is used for printk() functions. When you changed it to use UART1 (which maps to UARTE1 peripheral), you are enabling two UART peripherals, which goes to two different pin-outs.

    When you plug in the DK, it will give you 3 COM ports. Try opening them all with 115k2 baud, hit the reset-button and see which shows "UART loopback start!"

    This is the terminal connected to UARTE0 peripheral.

    The one that does not show any data is likely to be the one connected to the UARTE1 peripheral. Try sending any data to this one, and it should then be printed in the same terminal as "UART loopback start!" was shown in.

     

    If you try to probe the P0.00 and P0.01 on the pinlist, they will not show anything, as these GPIOs are connected directly to the VCOM1 interface on the Segger IC.

     

    Kind regards,

    Håkon

  • Hi, I am having a similar issue. I setup the nRf9160 with the UART sample and I get some characters when I type in one of the serial port. However, the data received appear to be only 0 or 128 if I print the decimal value in the UART CB. Any ideas on what could be the issue? Thanks.

    Regards,

    Corentn

  • If you have setup the example as being discussed in this thread, you should send data in one COM port, while the other should print it.

    It is a loopback of UART1 over the UART0 interface.

     

    If you have a different setup than what is discussed in this thread, I would recommend that you start a new thread.

     

    Kind regards,

    Håkon

  • Dear Håkon, 

    I am trying your suggestion, 

    If I use the UART0, just send and receive on UART0, it works, 

    the code: 

    #include <zephyr.h>
    #include <misc/printk.h>
    #include <uart.h>
    
    static u8_t uart_buf[1024];
    
    void uart_cb(struct device *x)
    {
    	uart_irq_update(x);
    	int data_length = 0;
    
    	if (uart_irq_rx_ready(x)) {
    		data_length = uart_fifo_read(x, uart_buf, sizeof(uart_buf));
    		uart_buf[data_length] = 0;
    	}
    	printk("%s", uart_buf);
    }
    
    void main(void)
    {
    	struct device *uart = device_get_binding("UART_0");
    
    	uart_irq_callback_set(uart, uart_cb);
    	uart_irq_rx_enable(uart);
    	printk("UART loopback start!\n");
    	while (1) {
    		k_cpu_idle();
                    
    	}
    }
    

    I can receive the data I  send at the same UART9 (COM12,115200bps,8N1,no handshake)

    I tried to send data ("hello") and received "hello" from the same UART0

    Then, I change to UART1 to send data:

    struct device *uart = device_get_binding("UART_1");

    Then, reprogramme, then check: still NO data out on the UART0 (printk)

    I tried to send data ("hello") from 2others COM, but UART0 didnt receive it.

    What do you think?

    Thanks so much

    hng

  • Dear Håkon, 

    I fixed it now, I deleted the folder /build and rebuild again

    I could redefine the pin for UART0/UART1 also.

    Thanks

    Regards,

    hng

Related