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

  • Oh, one difference between the two I forgot to mention is that the hal_twi code doesn't configure any pull-ups on the TWI pins. The design it's originally used in has 4.7 kOhm external pull resistors on the SDA and SCL lines. Does your design have any external pull resistors? If not, try configuring the pins with GPIO_PIN_CNF_PULL_Pullup instead of GPIO_PIN_CNF_PULL_Disabled.

Reply
  • Oh, one difference between the two I forgot to mention is that the hal_twi code doesn't configure any pull-ups on the TWI pins. The design it's originally used in has 4.7 kOhm external pull resistors on the SDA and SCL lines. Does your design have any external pull resistors? If not, try configuring the pins with GPIO_PIN_CNF_PULL_Pullup instead of GPIO_PIN_CNF_PULL_Disabled.

Children
No Data
Related