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

Using UART2 in Asset_Tracker example

I want to expand the Asset_Tracker example by adding the possibility to send data through UART2 to the controller and then to the nRF Cloud.

I am unable to find any document explaining what is necessary to do so that compilation then works.

I added 

CONFIG_SERIAL=y
CONFIG_TRUSTED_EXECUTION_NONSECURE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_2_NRF_UARTE=y

to the prj.conf but when I add 

 struct device *uart2 = device_get_binding("UART_2");
 uart_irq_callback_set(uart2, uart_cb);

to my main loop the program crashes.

Is there a document stating what to include and where, with explanation of what is being done and why? 

Also interesting to know where to set the pins for the UART2: I would like to have TXD on P0.11, RXD on P0.12.

Parents
  • Hi,

     

    To enable and set the GPIOs used for UART2, you need to specify this in a dts overlay file. The overlay file should be named $board_name.overlay, in most cases: nrf9160_pca10090ns.overlay

    The lte_ble_gateway example has such a file present, where it enables UART2. Your file should look like this:

    &uart2 {
    	current-speed = <115200>;
    	status = "ok";
    	tx-pin = <11>;
    	rx-pin = <12>;
    	/* Set to FFFFFFFF to disconnect/disable */
    	rts-pin = <0xFFFFFFFF>;
    	cts-pin = <0xFFFFFFFF>;
    };

     

    Store this to ncs/nrf/samples/nrf9160/my_application/nrf9160_pca10090ns.overlay, then re-import the project to get the new settings applied.

    Could you try and see if it works as expected now?

     

    Kind regards,

    Håkon

  • Hi:

    I tried adding the nrf9160_pca10090ns.overlay and it works. Thanks.

    I had tried it before and it didn't work because I was using the name nrf9160_pca10090.overlay (the ´ns´was missing!).

    Thanks.

Reply Children
Related