Change I2C clock speed without reinitializing

cskilbeck
Posts: 11
Joined: Tue Dec 10, 2019 10:40 pm

Change I2C clock speed without reinitializing

Postby cskilbeck » Sat Oct 28, 2023 12:09 pm

I have two I2C devices, one supports 1Mbit, the other supports 400Kbit. I would like to use the fast device at the fast speed but if I initialize the I2C device with `i2c_param_config` at 1Mbit then, when I want to communicate with the slow device I need to change the clock speed to 400Kbit.

At the moment I am tearing the I2C driver down and reinitializing it, but this isn't ideal.

Is it supported to call `i2c_param_config` after `i2c_driver_install` with a different clock speed?

If not, am I required to leave the clock speed at 1Mbit and change the timings with `i2c_set_period`, `i2c_set_start_timing` etc?

username
Posts: 509
Joined: Thu May 03, 2018 1:18 pm

Re: Change I2C clock speed without reinitializing

Postby username » Sat Oct 28, 2023 10:59 pm

The way I got arround this same issue was to set up of them instead of just one. Set the parameters for the first one with the fast clk speed, then set the second with the slower one. The trick is to use the same pins for both.

cskilbeck
Posts: 11
Joined: Tue Dec 10, 2019 10:40 pm

Re: Change I2C clock speed without reinitializing

Postby cskilbeck » Tue Oct 31, 2023 11:53 am

Thanks for this - I'm not sure I understand what you mean when you say 'set up {two} of them instead of just one' - can you clarify what functions you're calling to do this?

Who is online

Users browsing this forum: devlat, khervey and 100 guests