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

nRF9160 AT client UART0 pins reassignment issue

Hi,

I have a custom board based on nRF9160 for which I created custom .dts following porting guide.
It seems TX isn't sending anything (stay close to 0V) - config I have is: tx-pin = <8>; rx-pin = <9>; 
for &uart0, no handshake, reset level at 2.7V.
Checked prj.conf and .config they settings there seem alright. Please advise, what I might be missing here?
Thanks.

Parents
  • Could you upload your sample or a simplified version of it? Then I'll test it myself and see if there is something wrong with the DTS files or the configuration.

    Best regards,

    Simon

  • Thanks Simon,

    Please see .dts and prj,conf attached - had to change file extensions to get rid of file upload errors here to this
    ticket. Also note my software setup details and key pin measurements: 

    Software/ Firmware version/ settings: 
    * modem f/w v1.2.0 - programmed first (after erase all) using nRF Connect desktop (v3.4.1)/ Programmer (v1.4.3)
    * after modem f/w - next I flash Erase/ Write serial_link_modem from nrf connect sdk (ncs) v1.3.0. This hex built 
      using SES and custom dts (attached).

    Key pin measurements: 
    * VDD 3.3V
    * Reset pin (driven from external processor) 2.7V

    The problem I'm facing, despite correct (uart0) settings in .config - nRF9160 doesn't seem to drive tx-pin (8).
    Am I supposed to modify any other file (other than the .dts attached)? I read somewhere about overlay file - 
    what does that do? Also, for config changes - am I supposed to change prj.conf or menuconfig/ defconfig?

    Another observation, - I see nrf9160dk_nrf9160ns.overlay in \ncs\v1.3.0\nrf\applications\serial_lte_modem 
    but I don't see one for my custom board profile. Should there be one?

    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    #
    # General config
    CONFIG_LOG=y
    CONFIG_LOG_DEFAULT_LEVEL=3
    CONFIG_STACK_SENTINEL=y
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    
    # Segger RTT
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_NATIVE=n
    
    # BSD library
    CONFIG_BSD_LIBRARY=y
    # Enable below for modem trace
    #CONFIG_BSD_LIBRARY_TRACE_ENABLED=y
    
    # Use GPIO
    CONFIG_GPIO=y
    CONFIG_GPIO_NRFX=y
    CONFIG_GPIO_NRF_P0=y
    
    # UART interface
    CONFIG_SERIAL=y
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_TIMER2=y
    
    # LTE link control
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    
    # Stacks and heaps
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192
    
    # AT_CMD
    # Enable AT_CMD debug for details
    #CONFIG_AT_CMD_LOG_LEVEL_DBG=y
    
    # Device power management
    CONFIG_DEVICE_POWER_MANAGEMENT=y
    
    # Enable SUPL client support
    #CONFIG_SUPL_CLIENT_LIB=y
    
    # Application-specific
    CONFIG_SLM_LOG_LEVEL_INF=y
    # Enable GPIO wakeup if sleep is expected
    #CONFIG_SLM_GPIO_WAKEUP=y
    # Use UART_0 (when working with PC terminal)
    CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2
    # Use UART_2 (when working with external MCU)
    #CONFIG_SLM_CONNECT_UART_2=y
    #CONFIG_UART_2_NRF_HW_ASYNC_TIMER=2
    # Use optional TCP/TLS Proxy
    #CONFIG_SLM_TCP_PROXY=y
    # Use optional UDP/DTLS Proxy
    #CONFIG_SLM_UDP_PROXY=y
    
    /*
     * Copyright (c) 2018-2020 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    / {
    	model = "ECS nRFstamp";
    	compatible = "ECS,nrf9160_nRFstamp91";
    
    	chosen {
    		zephyr,console = &uart0;
    		zephyr,shell-uart = &uart0;
    		zephyr,uart-mcumgr = &uart0;
    	};
    
    	leds {
    		compatible = "gpio-leds";
    		led0: led_0 {
    			gpios = <&gpio0 1 0>;
    			label = "Green LED 1"; /*Load Switch*/
    		};
    	};
    
    	pwmleds {
    		compatible = "pwm-leds";
    		pwm_led0: pwm_led_0 {
    			pwms = <&pwm0 0>; /*<3> LED/SW1 | <0> Stamp#7 used on Edge.lite*/
    		};
    	};
    
    	buttons {
    		compatible = "gpio-keys";
    		button0: button_0 {
    			gpios = <&gpio0 14 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Switch 1"; /*JS button*/
    		};
    		button1: button_1 {
    			gpios = <&gpio0 2 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
    			label = "Switch 2"; /*BSP3*/
    		};
    	};
    
    	/* These aliases are provided for compatibility with samples */
    	aliases {
    		led0 = &led0;
    		pwm-led0 = &pwm_led0;
    		sw0 = &button1;
    		sw1 = &button0;
    	};
    };
    
    &adc {
    	status = "okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &uart0 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <8>;
    	rx-pin = <9>;
    };
    
    &uart1 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <29>;  /*HCI.TXO > nRF52(15)*/
    	rx-pin = <28>;  /*HCI.RXO < nRF52(16)*/
    	rts-pin = <27>; /*HCI.RTS > nRF52(18)*/
    	cts-pin = <26>; /*HCI.CTS < nRF52(20)*/
    };
    
    &uart2 {
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <24>;
    	rx-pin = <23>;
    };
    
    &i2c2 {
    	compatible = "nordic,nrf-twim";
    	status = "okay";
    	sda-pin = <6>;
    	scl-pin = <7>;
    };
    
    &pwm0 {
    	status = "okay";
    	ch0-pin = <0>; /*<3> LED/SW1 | <0> Stamp#7 used on Edge.lite*/
    };
    
    &spi3 {
    	compatible = "nordic,nrf-spim";
    	status = "okay";
    	sck-pin = <12>;
    	mosi-pin = <10>;
    	miso-pin = <11>;
    };
    
    &timer0 {
    	status = "okay";
    };
    
    &timer1 {
    	status = "okay";
    };
    
    &timer2 {
    	status = "okay";
    };
    
    &flash0 {
    	/*
    	 * For more information, see:
    	 * http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
    	 */
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x00000000 0x10000>;
    		};
    		slot0_partition: partition@10000 {
    			label = "image-0";
    		};
    		slot0_ns_partition: partition@40000 {
    			label = "image-0-nonsecure";
    		};
    		slot1_partition: partition@80000 {
    			label = "image-1";
    		};
    		slot1_ns_partition: partition@b0000 {
    			label = "image-1-nonsecure";
    		};
    		scratch_partition: partition@f0000 {
    			label = "image-scratch";
    			reg = <0x000f0000 0xa000>;
    		};
    		storage_partition: partition@fa000 {
    			label = "storage";
    			reg = <0x000fa000 0x00006000>;
    		};
    	};
    };
    
    / {
    
    	reserved-memory {
    		#address-cells = <1>;
    		#size-cells = <1>;
    		ranges;
    
    		sram0_s: image_s@20000000 {
    			/* Secure image memory */
    		};
    
    		sram0_bsd: image_bsd@20010000 {
    			/* BSD (shared) memory */
    		};
    
    		sram0_ns: image_ns@20020000 {
    			/* Non-Secure image memory */
    		};
    	};
    };
    
    /* Include partition configuration file */
    #include "nrf9160_nRFstamp91_partition_conf.dts"
    
      

    Best,
    SE

  • Smart.Enrg said:
    Am I supposed to modify any other file (other than the .dts attached)? I read somewhere about overlay file - 
    what does that do?

    The overlay file can be used to overwrite the fields of the DTS nodes in the board folder (e.g. the rx and tx pins of uart0). However, it shouldn't be necessary in your case, since the tx and rx pin are set to the desired values.

    Smart.Enrg said:
    Also, for config changes - am I supposed to change prj.conf or menuconfig/ defconfig?

     Since you're using uart0, make sure CONFIG_SLM_CONNECT_UART_0=y and CONFIG_SLM_CONNECT_UART_2=n, you can confirm that the configurations are set correctly by checking the file ncs\v1.3.0\nrf\applications\serial_lte_modem\build\zephyr\include\generated\autoconf.h (you have to build your application first). 

    Smart.Enrg said:
    Another observation, - I see nrf9160dk_nrf9160ns.overlay in \ncs\v1.3.0\nrf\applications\serial_lte_modem 
    but I don't see one for my custom board profile. Should there be one?

    I looked inside the file ncs\v1.3.0\nrf\applications\serial_lte_modem\nrf9160dk_nrf9160ns.overlay and saw that it only configured uart2. You are using uart0, and it is already configured in the file nrf9160_nRFstamp91_common_dts.txt, so I don't think you need to add an overlay file for your board.

    One way to check if the fields for uart0 is set correctly is to look inside the file ncs\v1.3.0\nrf\applications\serial_lte_modem\build\zephyr\include\generated\devicetree_unfixed.h. Check if DT_N_S_soc_S_peripheral_40000000_S_uart_8000_P_tx_pin (I think that is the correct name) is equal to 8.

    A cleaner approach is to run printk("TX pin: %d\n"DT_PROP(DT_NODELABEL(uart0), tx_pin)) in ncs\v1.3.0\nrf\applications\serial_lte_modem/src/main.c-->main().


    Could you check one thing? The application slm_at_host.c won't send data (use tx pin), until it has received (use rx pin) a complete AT command in uart_rx_handler(), submitted a work queue item which triggers cmd_send(), sent it to the modem, received a response from the modem. Then it will send the response (use the tx pin).

    Could you set a breakpoint or add some logging at the bottom of static void uart_rx_handler(..):

    tatic void uart_rx_handler(u8_t character)
    {
        .
        .
        .
    send:
        //Check if it goes here
    	uart_rx_disable(uart_dev);
    	k_work_submit(&cmd_send_work);
    	at_buf_len = cmd_len;
    	cmd_len = 0;
    }

    You could also do some debugging in cmd_send() and check if rsp_send() runs.

    Best regards,

    Simon

Reply
  • Smart.Enrg said:
    Am I supposed to modify any other file (other than the .dts attached)? I read somewhere about overlay file - 
    what does that do?

    The overlay file can be used to overwrite the fields of the DTS nodes in the board folder (e.g. the rx and tx pins of uart0). However, it shouldn't be necessary in your case, since the tx and rx pin are set to the desired values.

    Smart.Enrg said:
    Also, for config changes - am I supposed to change prj.conf or menuconfig/ defconfig?

     Since you're using uart0, make sure CONFIG_SLM_CONNECT_UART_0=y and CONFIG_SLM_CONNECT_UART_2=n, you can confirm that the configurations are set correctly by checking the file ncs\v1.3.0\nrf\applications\serial_lte_modem\build\zephyr\include\generated\autoconf.h (you have to build your application first). 

    Smart.Enrg said:
    Another observation, - I see nrf9160dk_nrf9160ns.overlay in \ncs\v1.3.0\nrf\applications\serial_lte_modem 
    but I don't see one for my custom board profile. Should there be one?

    I looked inside the file ncs\v1.3.0\nrf\applications\serial_lte_modem\nrf9160dk_nrf9160ns.overlay and saw that it only configured uart2. You are using uart0, and it is already configured in the file nrf9160_nRFstamp91_common_dts.txt, so I don't think you need to add an overlay file for your board.

    One way to check if the fields for uart0 is set correctly is to look inside the file ncs\v1.3.0\nrf\applications\serial_lte_modem\build\zephyr\include\generated\devicetree_unfixed.h. Check if DT_N_S_soc_S_peripheral_40000000_S_uart_8000_P_tx_pin (I think that is the correct name) is equal to 8.

    A cleaner approach is to run printk("TX pin: %d\n"DT_PROP(DT_NODELABEL(uart0), tx_pin)) in ncs\v1.3.0\nrf\applications\serial_lte_modem/src/main.c-->main().


    Could you check one thing? The application slm_at_host.c won't send data (use tx pin), until it has received (use rx pin) a complete AT command in uart_rx_handler(), submitted a work queue item which triggers cmd_send(), sent it to the modem, received a response from the modem. Then it will send the response (use the tx pin).

    Could you set a breakpoint or add some logging at the bottom of static void uart_rx_handler(..):

    tatic void uart_rx_handler(u8_t character)
    {
        .
        .
        .
    send:
        //Check if it goes here
    	uart_rx_disable(uart_dev);
    	k_work_submit(&cmd_send_work);
    	at_buf_len = cmd_len;
    	cmd_len = 0;
    }

    You could also do some debugging in cmd_send() and check if rsp_send() runs.

    Best regards,

    Simon

Children
No Data
Related