Page 1 of 1
STM32F103 I2C change mapping on fly
Posted: Fri Jun 11, 2021 7:11 am
by Tuxford
There is a case when two pairs PB6/PB7 and PB8/PB9 are used with different I2C slaves on I2C1. Is it possible change only AFIO->MAPR without i2cStart/i2cStop or restart it required?
Chibios 20.3
Re: STM32F103 I2C change mapping on fly
Posted: Fri Jun 11, 2021 8:12 am
by Giovanni
Hi,
It is not safe in my opinion, you could have glitches pm SDA/SCL depending on how GPIO is designed. Make sure to not do that while I2C is active anyway.
Giovanni
Re: STM32F103 I2C change mapping on fly
Posted: Fri Jun 11, 2021 10:49 am
by Tuxford
Giovanni wrote:Hi,
It is not safe in my opinion, you could have glitches pm SDA/SCL depending on how GPIO is designed. Make sure to not do that while I2C is active anyway.
Giovanni
Read/Write operations are protected. So so switching mode is not performed during activity. It is just question of software.
Re: STM32F103 I2C change mapping on fly
Posted: Sun Jun 13, 2021 8:04 am
by rew
I would think that the IO pad design on the chip is synchronous. So if you change from AFx to GPIO on the fly, at one point the I2C module is providing the data driving the pin and the next clock it will revert back to the ODR. This is just like changing another pin in the same ODR: Glitches would be bad.
I think it is safe and can be done. Won't hurt to check for yourself though. The critical moment is when you switch from GPIO to I2C and back. So you can just do that switch a million times a second without sending any I2C data, so you can see if the scope triggers on anything, and test it a 100 million times in under two minutes....