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

Zephyr I2C Write Hangs

Howdy,

I'm using Zephyr to configure an nRF52840 to act as an I2C master and send data to a TM4C slave at a 100kHz clock rate. The nRF52840 appears to hang after calling i2c_transfer:

    char buffer = "B";
    struct i2c_msg msg;
    msg.buf = (u8_t *)buffer;
    msg.len = 1;
    msg.flags = I2C_MSG_WRITE | I2C_MSG_STOP;

    i2c_transfer(mdi_i2c_device, &msg, 1, I2C_ADDRESS);
Attached is an image of the logic analyzer trace of the SDA and SCL lines, as well as the analog traces. The address is submitted to the bus (1st red box), and the slave acknowledges it (first yellow box), and then the letter "B" is sent (2nd red box), and again the slave acknowledges it (2nd yellow box). The code never returns from i2c_transfer. I've tried changing the I2C_MSG_STOP to I2C_MSG_RESET, and i2c_transfer does return the first time, but not subsequent times.
Any advice would be appreciated!
Austin
  • Oh, my prj.conf file has the following:

    #Flash
    CONFIG_FLASH=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y

    #Bluetooth Configuration
    CONFIG_BT=y
    CONFIG_BT_DEBUG_LOG=y
    CONFIG_BT_SMP=y
    CONFIG_BT_SIGNING=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_GATT_DIS=y
    CONFIG_BT_ATT_PREPARE_COUNT=2
    CONFIG_BT_PRIVACY=y
    CONFIG_BT_DEVICE_NAME="Device Name"
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_DEVICE_NAME_MAX=65
    CONFIG_BT_SETTINGS=y
    #CONFIG_BT_BONDABLE=y

    #I2C
    CONFIG_I2C=y
    CONFIG_I2C_0=y

    #Dynamic Memory Heap Size
    CONFIG_HEAP_MEM_POOL_SIZE=1024

    #Log Config
    CONFIG_PRINTK=y
    CONFIG_LOG=y
    CONFIG_LOG_DEFAULT_LEVEL=4
    CONFIG_LOG_MODE_OVERFLOW=y
    CONFIG_LOG_PRINTK=y

    #Segger Config
    #CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=n
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_LOG_BACKEND_RTT=y

    CONFIG_DEBUG_OPTIMIZATIONS=y
    CONFIG_EXCEPTION_STACK_TRACE=y
    CONFIG_DEBUG_INFO=y

    #GPIO
    CONFIG_GPIO=y

    #UART Config
    CONFIG_SERIAL=y
    # CONFIG_UART_CONSOLE=n
    #CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_UART_ASYNC_API=y
    #CONFIG_UART_ASYNC_API=y
    #CONFIG_UART_0_INTERRUPT_DRIVEN=y
    #CONFIG_UART_0_INTERRUPT_DRIVEN=y
    #CONFIG_UART_0_ASYNC=y
    #CONFIG_UART_NRF=y
  • One more piece of data:

    I've hooked up the nRF52840 to an Arduino Due and everything seems to be working, including a response from the slave, in this case the letter "C". Still not solved, as there seems to be an issue between the nRF52840 -> TM4C.

  • Ok, the issue was with the TM4C, the interrupt vector on the I2C peripheral wasn't configured correctly. Can confirm that Zephyr nRF52840 I2C is indeed working with the below prj.conf settings.

Related