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

I2C clock frequency problem

Hi,

I am using NRF52832 development board , to which i have interfaced LIS3DSH accelerometer sensor(3.3V i2c)

when i  configure it for 1600 sampling rate and all the axis enabled , i am not able to get any data .

could anyone help with this problem.

also the I2c clock frequency, as shown in below image, while i am capturing data when i observe in oscilloscope or logic analyzer , clock frequency is showing 200 all the setting is for 400KHz.

what could be the problem for this or is there any other way i need to follow to set the clock to 400KHz.

help me ASAP...

Thank you

Parents Reply Children
  • TWI

    ok sorry , now i understood , but sill value is updated as u can see in this one.

  • The FREQUENCY register is actually shared between the TWI, TWIM, SPI, and SPIM peripherals, but, they all use different sets of values to represent their settings:

    The TWI's FREQUENCY register docs have defined K400 as 0x06680000, whereas the TWIM's FREQUENCY register docs have defined K400 as 0x06400000. 

    There's actually a bug in the legacy TWI drivers where it uses 0x06680000 when you use the SPIM peripheral. It's not really critical as you'll just get ~410kHz instead of 400kHz, and slaves are usually okay with a bit higher clock rate than 400kHz. 



    The 200kHz clock you see is probably not the sole product of the TWI/M peripheral, I think there's something on your bus that interferes with your signals. 

    Are you able to reproduce the issue on the DK, and can you show us a scope of the clock when running on the DK with no devices attached?

  • can u explain what exactly i should do now, without any device means

    is it generating PWM.

  • "without any devices" means exactly that - nothing connected to the I2C lines!

    Nothing except the pullups, of course!

    In that situation, you should see the Master sending the Slave Address.

    Because there is no Slave attached, the Master will see that as a NAK - but it will be enough to see the Clock ...

  • Without any TWI slaves attached to the bus.

    I want to see the scope of the clock signal.