This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unable to get Interrupt for I2C TWIS while using AWS IoT

Hi everyone,

first time posting here for me, let me know if i'm doing it wrong.

I'm currently developing a "modem module" built around nrf9160 and working with AWS using NBIoT. The module will be added to a device which will communicate with it through I2C. The nrf9160 will be the slave device on the bus and will receive data to publish on AWS using MQTT.

I tested the"aws IoT" example and it's working correctly.

I build a sample code to receive the data on I2C using TWIS library since Zephyr doesn't support Slave I2C with its drivers. This code is working fine and i'm able to receive the data into a buffer and work on them. Here the interesting part of the code i used for the I2C slave:

Here the prj.conf sed to test the i2c:

Fullscreen
1
2
CONFIG_NRFX_TWIS=y
CONFIG_NRFX_TWIS2=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Here the overlay used to test the I2C:

Fullscreen
1
2
3
4
5
6
7
&i2c2 {
compatible = "nordic,nrf-twis";
status = "okay";
sda-pin = <30>;
scl-pin = <31>;
clock-frequency = <I2C_BITRATE_STANDARD>;
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Here the actual code used to test the i2c:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <zephyr.h>
#include <device.h>
#include <devicetree.h>
#include <nrfx_twis.h>
#include <irq.h>
#define NBIOT_MODULE_SLAVE_ADDR (0x60)
#define JSON_BUFFER_SIZE 600
#define DATA_TRANSFER_BLOCK_SIZE 64
typedef nrfx_twis_t nrf_drv_twis_t;
static const nrfx_twis_t m_twis = NRFX_TWIS_INSTANCE(2);
char data_received[DATA_TRANSFER_BLOCK_SIZE + 1];
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This code works perfectly.

The problem arises when I try to add the i2c part to the aws IoT example. Just by inserting the same code and performing the same initialization, the system is not able to enter the twis_event_handler function nor the system is providing ACK on the I2C bus.

I checked the return value of the nrfx_twis_init   function and i'm getting  NRFX_SUCCESS so the peripheral should be initalized correctly

Here is the prj.conf of the complete code (mainly the same as for aws IoT example with I2C and some APN configuration added):

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# General config
CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_REBOOT=y
# NEWLIB C
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
# Network
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_NETWORK_MODE_LTE_M=n
CONFIG_LTE_NETWORK_MODE_NBIOT=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
CONFIG_PDN=y
CONFIG_PDN_DEFAULTS_OVERRIDE=y
CONFIG_PDN_SYS_INIT=y
# Note: "ip" is set by PDN_DEFAULT_FAM kconfig's
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The overlay file is the same as before.

Am I missing some configuration that has to be done? Are there any conflicts between peripherals that are blocking the I2C?

Thank you in advance for any help

Nicolò

Parents
  • Hi Jared,

    Yes the TWIS peripheral is running in non-secure.

    Am i missing some configurations of the SPM?

    Thanks,

    Nicolò

  • Hi,

    Does the AWS IoT part work? Is there any output on the log?

  • Hi,

    Yes the AWS part is working completely fine, it's like the i2c part is not present.

    As i said before i'm unable to reach interrupt on i2c messages or even get ACK, that's the strange thing.

    It seems that something is interfering with the peripheral.

    I event tried to move to TWIS3 but without success.

    Nicolò

Reply
  • Hi,

    Yes the AWS part is working completely fine, it's like the i2c part is not present.

    As i said before i'm unable to reach interrupt on i2c messages or even get ACK, that's the strange thing.

    It seems that something is interfering with the peripheral.

    I event tried to move to TWIS3 but without success.

    Nicolò

Children
  • Hi,

    Are you using any other peripheral than UART0(AWS IoT) in your example? It might be a conflict of resources if you're using more than one peripheral with the same ID. Are you able to use any other simpler peripheral such as the GPIO peripheral?

    regards

    Jared 

  • Hi, 

    i'm able to use GPIO without any problem. I've actually added a blinking LED to help me debug the AWS IoT example when i was configuring APN and other things.

    As i said before i switched to TWIS3 to try but still no luck.

    I checked in the .config files both for SPM and the application and all the peripheral sharing the same ID (SPIS3, SPIM3, UARTE3) are not enabled. 

    To get SPI3 to be disabled i added the following to the application overlay file both in the application overlay and in the spm overlay:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    &spi3 {
    status = "disabled";
    };
    &uart3 {
    status = "disabled";
    };
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Still no luck even with these

  • Hi there,

    Could you share your entire project?

    regards

    Jared 

  • Hi Jared, sorry for my late reply.

    In the end i solved the problem by removing the line 

    CONFIG_NCS_SAMPLES_DEFAULTS=y

    from the prj.conf file.

    I tested this by adding all the prj.conf lines one by one to a project with only the i2c part and the spm were present until i found the line that was blocking the i2c peripheral.

    I'm not sure why this configuration was causing problems but i think is related to the spm.

    Thank you for your time, i hope that my solution will be helpful to others

  • Hi,

    Not sure exactly why this helped, but that config will turn on the UART since it activates the logger module.

    Anyways, I'm happy that you returned with the solution. I'm sure it will help others on this forum.

    best regards

    Jared