I2C stops working on nRF9160-DK board version 1.1.0 when SW9 is switched to non default 3V position

I have ported a sample program and library from Arduino to Zephyr and start the code in asset_tracker_v2 main(). This is what I am testing: E-paper Display Kit - Ynvisible. The recommendation from Ynvisible is to run their hardware at 3.3 volts. It actually works on the nRF9160-DK version 1.1.0 with SW9 set to the 1.8v VDD position, using P0-31 for SCL, P0-30 for SDA, and P1 for GND and VDD.

But when I switch S9 to 3.0v VDD, I get I/O errors from I2C: 

*** Booting nRF Connect SDK v2.5.0 ***
The I2C scanner started
Value of NRF_TWIM2->PSEL.SCL : 31
Value of NRF_TWIM2->PSEL.SDA : 30
Value of NRF_TWIM2->FREQUENCY: 26738688
26738688 -> 100k
YNV_ECD display i=-99
[00:00:01.254,272] <err> i2c_nrfx_twim: Error on I2C line occurred for message 0
YNV_ECD::sendData i2c_write rc=-5
[00:00:05.754,882] <err> i2c_nrfx_twim: Error on I2C line occurred for message 0
YNV_ECD::sendData i2c_write rc=-5

I didn't spot anything obvious in the DK user manual explaining why I2C would stop working. It seems strange that my I2C device would work fine at 1.8v but not at 2.9-3.0 volts when it is spec'd to work at 3.3 VDC. What am I missing? Do I need to reconfigure something else on the DK board? Thank you.

Burt

ps, using SDK v2.5.0

Parents
  • Hello DevZone, I am ready for a bit more help. The engineering team at Ynvisible recommended that I slow the I2C bus down from 100 kHz to 10 kHz. I did this using the Zephyr bitbang I2C software driver and I had SUCCESS. I would like to try this with a temporary hack to the hardware driver code in modules/hal/nordic/nrfx/mdk/nrf9160_bitfields.h: the line

    #define TWIM_FREQUENCY_FREQUENCY_K100 (0x01980000UL) /*!< 100 kbps */

    I would like to change the number for 0x019800000 to a number that will give a slightly slower bus. I would be grateful if you could provide me with a formula for choosing the value, given bus frequency as input. So I could try 95kHz, 90kHz,... to see how far down I have to go in order to have success. One of the hardware engineers must know a formula. I know it's a bit ugly but we want something that works. Thanks, please get back to me.

    Burt

  • Hi Burt,

    There is a older reply on a UART case but the formula is the same for TWI, https://devzone.nordicsemi.com/f/nordic-q-a/391/uart-baudrate-register-values/2046 .

    The formula is: Baudrate = desired baudrate * 2^32 / 16000000

    Regards,
    Jonathan

  • Thanks, Jonathan. I experimented and found that my Ynvisible hardware worked when I dropped the Baudrate register to 0x17F0000; used a scope to see 93 kHz, not realizing that the Baudrate is linear. All good. But just curious, does Nordic Semi produce any parts that use a different hardware TWIM? I know that would not help me; I just wish the hardware could be set to 100 kHz and be compatible with Ynvisible because Arduino Atmel chips work that way. You know, something about the way clock stretching is done.

Reply
  • Thanks, Jonathan. I experimented and found that my Ynvisible hardware worked when I dropped the Baudrate register to 0x17F0000; used a scope to see 93 kHz, not realizing that the Baudrate is linear. All good. But just curious, does Nordic Semi produce any parts that use a different hardware TWIM? I know that would not help me; I just wish the hardware could be set to 100 kHz and be compatible with Ynvisible because Arduino Atmel chips work that way. You know, something about the way clock stretching is done.

Children
Related