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

How can i use 4 Serial peripheral interface on nrf9160

I created a project on nrf9160, which connects many peripherals, including SPI,I2C,UART. According to the specification, nrf9160 can use up to 4 sets of serial peripherals at the same time because of address sharing. However, the actual situation is that when I use SPI2,SPI3,I2C1 at the same time, I can't get the binding of SPI2, and when I use SPI2,SPI3,UART1 at the same time, they are all ok, why?

  • If so, can I turn off Console and Logging and use I2C_0 as 9160 to communicate with peripherals?Now I have tried this and can also obtain binding, but in fact I2C cannot communicate, there is no corresponding message display peripheral, and it seems that the SCL and SDA pin of I2C are occupied by other functions.

    I used an oscilloscope to capture the waveform and found that the waveform could be normally seen using I2C_2, but the waveform could not be seen after using I2C_0. It seemed that the SCL was forcibly restricted to a high level by an application.

  • Hi,
    Could you share your latest prj.conf file?
    Also I would advice you to port your project to NCS 1.4.0 and do a re-test.

    I suspect that you are running on NCS1.2.0 and there was an issue with similar symptoms as you see in that version.
     

  • Thank you for your reply. This is the content of my PRJ. Conf file, please check it:

    #
    # Copyright (c) 2019 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    #
    # General config
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_ASSERT=y
    CONFIG_REBOOT=y
    CONFIG_GPIO=y
    CONFIG_TRUSTED_EXECUTION_NONSECURE=y
    
    # Log
    CONFIG_PRINTK=n
    CONFIG_LOG=y
    CONFIG_LOG_IMMEDIATE=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_CONSOLE=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    
    # Modem info
    CONFIG_MODEM_INFO=y
    
    # BSD library
    CONFIG_BSD_LIBRARY=y
    CONFIG_BSD_LIBRARY_TRACE_ENABLED=n
    
    # Flash
    CONFIG_FLASH=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    
    # NVS
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_NVS=y
    CONFIG_NVS_LOG_LEVEL_DBG=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    # GPS
    CONFIG_AT_CMD=n
    CONFIG_AT_NOTIF=n
    
    # AT_CMD
    CONFIG_AT_HOST_LIBRARY=n
    CONFIG_UART_INTERRUPT_DRIVEN=n
    
    # Console
    CONFIG_CONSOLE_SUBSYS=y
    CONFIG_CONSOLE_HANDLER=y
    CONFIG_CONSOLE_GETCHAR=y
    
    # Enable SUPL client support AGPS
    CONFIG_SUPL_CLIENT_LIB=n
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_NATIVE=n
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
    
    # LTE link control
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    #add by liming
    #CONFIG_POWER_OPTIMIZATION_ENABLE=n
    CONFIG_LTE_NETWORK_MODE_LTE_M_GPS=n
    #CONFIG_LTE_LINK_CONTROL_LOG_LEVEL_DBG=y
    CONFIG_LTE_NETWORK_MODE_NBIOT_GPS=y
    CONFIG_LTE_LEGACY_PCO_MODE=y
    #CONFIG_LTE_PSM_REQ_RPTAU="00000110"
    #CONFIG_LTE_PSM_REQ_RAT="00000010"
    
    # MQTT
    CONFIG_MQTT_LIB=y
    CONFIG_MQTT_LIB_TLS=y   
    #add by liming
    CONFIG_MQTT_CLIENT_ID="devzone_client"
    CONFIG_MQTT_BROKER_HOSTNAME="test.mosquitto.org"
    CONFIG_MQTT_BROKER_PORT=8884
    CONFIG_SEC_TAG=51966
    CONFIG_PEER_VERIFY=1
    
    # Appliaction
    #CONFIG_MQTT_PUB_TOPIC="/my/publish/topic"
    #CONFIG_MQTT_SUB_TOPIC="/my/subscribe/topic"
    #CONFIG_MQTT_CLIENT_ID="my-client-id"
    #CONFIG_MQTT_BROKER_HOSTNAME="mqtt.eclipse.org"
    #CONFIG_MQTT_BROKER_PORT=1883
    
    # Library for buttons and LEDs
    CONFIG_DK_LIBRARY=y
    CONFIG_DK_LIBRARY_INVERT_LEDS=n
    
    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    CONFIG_MAIN_STACK_SIZE=8192
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    CONFIG_HW_STACK_PROTECTION=y
    
    # MCUBOOT
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUBOOT_IMG_MANAGER=y
    
    # SPI
    CONFIG_SPI=y
    CONFIG_SPI_NRFX=y
    CONFIG_SPI_2=y
    CONFIG_SPI_2_NRF_SPIM=y
    CONFIG_SPI_3=y
    CONFIG_SPI_3_NRF_SPIM=y
    
    # I2C
    CONFIG_I2C=y
    CONFIG_I2C_NRFX=y
    CONFIG_I2C_0=y
    CONFIG_I2C_0_NRF_TWIM=y
    CONFIG_I2C_2=n
    CONFIG_I2C_2_NRF_TWIM=n
    CONFIG_I2C_INIT_PRIORITY=60
    
    # UART
    CONFIG_SERIAL=y
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_LINE_CTRL=y
    #CONFIG_UART_0_NRF_UARTE=n
    #CONFIG_UART_0_NRF_FLOW_CONTROL=n
    CONFIG_UART_1_NRF_UARTE=y
    CONFIG_UART_1_NRF_FLOW_CONTROL=n
    
    # Use smaller buffers for net_buf as CANBUS packets are quite small.
    CONFIG_NET_BUF_DATA_SIZE=64
    CONFIG_NET_BUF_USER_DATA_SIZE=1
    
    # Main thread
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_HEAP_MEM_POOL_SIZE=2048

  • You have to manually disable the UART_0 in the prj.conf, if not the project will use the default board settings.

    But please try this on the latest NCS as well.

Related