STM32F103 I2C change mapping on fly

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

Tuxford
Posts: 12
Joined: Fri Nov 06, 2020 3:28 pm
Has thanked: 2 times

STM32F103 I2C change mapping on fly

Postby Tuxford » Fri Jun 11, 2021 7:11 am

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

User avatar
Giovanni
Site Admin
Posts: 13629
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 888 times
Been thanked: 768 times
Contact:

Re: STM32F103 I2C change mapping on fly

Postby Giovanni » Fri Jun 11, 2021 8:12 am

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

Tuxford
Posts: 12
Joined: Fri Nov 06, 2020 3:28 pm
Has thanked: 2 times

Re: STM32F103 I2C change mapping on fly

Postby Tuxford » Fri Jun 11, 2021 10:49 am

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.

rew
Posts: 367
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: STM32F103 I2C change mapping on fly

Postby rew » Sun Jun 13, 2021 8:04 am

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....


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 3 guests