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

How to configure I2C frequency other than 100kHz 250kHz and 400Khz?

Hi All,

I am working on a project where i need to communicate using i2c protocol. For this i need to set i2c frequency 20 Khz. So how can i calculate register value to set 20 KHz frequency or what would be the register value for 20Khz frequency? 

As in the example project there three frequencies mentioned

#define TWI_FREQUENCY_FREQUENCY_K100 (0x01980000UL) /*!< 100 kbps */
#define TWI_FREQUENCY_FREQUENCY_K250 (0x04000000UL) /*!< 250 kbps */
#define TWI_FREQUENCY_FREQUENCY_K400 (0x06680000UL) /*!< 400 kbps (actual rate 410.256 kbps) */

So, it would be great help if you can set the frequency 20 Khz

platform: - Segger embedded studio

DK: NRF52832  

SDK Version: - 16.0.0

Regards 

Pradeep

Parents
  • Hello,

    Do you have a logic analyzer that you can use to measure the actual frequency?

    Can you try to set it to 0x00520000UL ?

    This is just calculations, rounded off. I don't remember whether it is the last 3 or 4 '0's that doesn't affect the actual frequency, and I don't have a logic analyzer at my home office to test. If you don't have a logic analyzer, you but a device that requires approx 20kHz, then you can test with this value, and see if it works. If that doesn't work, these values are also good candidates:

    0x00510000UL

    0x00500000UL

    Best regards,

    Edvin

Reply
  • Hello,

    Do you have a logic analyzer that you can use to measure the actual frequency?

    Can you try to set it to 0x00520000UL ?

    This is just calculations, rounded off. I don't remember whether it is the last 3 or 4 '0's that doesn't affect the actual frequency, and I don't have a logic analyzer at my home office to test. If you don't have a logic analyzer, you but a device that requires approx 20kHz, then you can test with this value, and see if it works. If that doesn't work, these values are also good candidates:

    0x00510000UL

    0x00500000UL

    Best regards,

    Edvin

Children
Related