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

s120 with TWI

I'm trying to use the TWI master example with the S120 soft device. It looks like there is a known problem trying to get the S110 working with the hardware TWI. It seems the TWI doesn't play well with the S120 either. I found this thread to get it working with the S110:

devzone.nordicsemi.com/.../

I tried the fix, but it doesn't seem to work with the S120. The TWI initializes now, but when I try to perform a read, it's causing a hard fault.

Does anyone know how to get the TWI master example working with the S120?

Parents
  • The TWI master example is set up to access the PPI registers directly without checking if the SoftDevice is enabled. When the softdevice is enabled, the sd_ppi_x functions must be used, as accessing the registers directly causes a HardFault.

    The attached hal_twi library will check to see if the SoftDevice is enabled and access the registers or SoftDevice API accordingly. I've also attached a driver file that utilizes the hal_twi library to access a IMU sensor as an example of use.

    Audun

  • We are using pull-ups, so that isn't the issue. After some close examination of the data on a scope, it looks like the S120 API isn't sending the register address correctly. The device address goes fine, but there is one less clock pulse than there should be. The last pulse is for the peripheral to ACK that it has received the last byte (the register address). It looks like the peripheral is waiting forever for the last clock pulse, which never shows up. I believe the S120, or something else Nordic related, has control of the clock at this point. I think that ACK bit is part of the I2C standard, so I wouldn't guess this is a configuration issue.

    Is the S120 SWI interface broken?

Reply
  • We are using pull-ups, so that isn't the issue. After some close examination of the data on a scope, it looks like the S120 API isn't sending the register address correctly. The device address goes fine, but there is one less clock pulse than there should be. The last pulse is for the peripheral to ACK that it has received the last byte (the register address). It looks like the peripheral is waiting forever for the last clock pulse, which never shows up. I believe the S120, or something else Nordic related, has control of the clock at this point. I think that ACK bit is part of the I2C standard, so I wouldn't guess this is a configuration issue.

    Is the S120 SWI interface broken?

Children
No Data
Related