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

  • That doesn't seem to work. My SDA line keeps getting stuck low for some reason, which doesn't happen with the twi_master code. Here is the init code:

    hal_twi_init_t twi_params;

    // 2-Wire initialization twi_params.scl_pin = TWI_CLK_PIN; twi_params.sda_pin = TWI_SDA_PIN; twi_params.frequency = hal_twi_freq_100khz; twi_params.ppi_chn = 3;

    hal_twi_init(&twi_params);

    After this I would think that SDA would be high, but it isn't. If I carry on with my code, sometimes it goes high, and tries to read data, but after transferring one byte (the device address), SDA sticks low again. If I erase the chip, and program my old code again, it works fine, so I don't think it's the device I am trying to talk to. I also checked to make sure that I'm using the same pins, and I am.

    Can you offer any other suggestions?

Reply
  • That doesn't seem to work. My SDA line keeps getting stuck low for some reason, which doesn't happen with the twi_master code. Here is the init code:

    hal_twi_init_t twi_params;

    // 2-Wire initialization twi_params.scl_pin = TWI_CLK_PIN; twi_params.sda_pin = TWI_SDA_PIN; twi_params.frequency = hal_twi_freq_100khz; twi_params.ppi_chn = 3;

    hal_twi_init(&twi_params);

    After this I would think that SDA would be high, but it isn't. If I carry on with my code, sometimes it goes high, and tries to read data, but after transferring one byte (the device address), SDA sticks low again. If I erase the chip, and program my old code again, it works fine, so I don't think it's the device I am trying to talk to. I also checked to make sure that I'm using the same pins, and I am.

    Can you offer any other suggestions?

Children
No Data
Related