I2C2 and SPI1 at the same time

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

Moderator: RoccoMarco

Post Reply
mukululul
Posts: 27
Joined: Thu Nov 28, 2013 4:22 pm

I2C2 and SPI1 at the same time

Post by mukululul »

Hi,
I am working with a STM32F103ZET and first I had I2C2 and SPI2 at the same time in use. SPI worked fine, I2C didn't.
Using the scope I could see that the HWaddr was send out but no no response from the slave was on the wire.
When I disable SPI I2C works perfect.
Then I saw this other post here in the Forum stating I2C2 and SPI2 at the same time does not work due to DMA.
Then I rewired my SPI to SPI1 thinking that this is using a different DMA.
Doing the test above I see the very same behaviour. SPI1 works and I2C2 sends out only the HWaddr.
I can't belive the STM hardware is so restricted in use.

Does anybody have a idea why this does not work?

Is this a restriction in Chibios or the STM HW?

Thanks for your help.

Michael
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C2 and SPI1 at the same time

Post by Giovanni »

You should give a look to the STM32F1 errata but I don't remember anything like this.

Edit: Actually there are several erratas regarding I2C in combination with SPI and USART....

14574_STM32F103_Errata.zip
(59.8 KiB) Downloaded 419 times


Are you stuck with the F1 device? you may consider switching to the F3.

Giovanni
mukululul
Posts: 27
Joined: Thu Nov 28, 2013 4:22 pm

Re: I2C2 and SPI1 at the same time

Post by mukululul »

Hi Giovanni,
thank you al lot for your fast reply. Even if the erratta did not contain a trace to the cause it kept me digging deeper.
By reducing the tests for the problem to a minimum I found out that the problem is not caused by SPI1.
The cause was a failing i2c device which is not there since the debug hw does not contain the device. It contains one SE95D (Temp Sensor), so the failing sequence is access to a i2c device which is not connected, then the access to the SE95D. This lead me to the error handling code where I did another i2cStart (without a i2cStop). I guess I miss read the documentation where the state diagram shows that the transition from LOCKED is i2cStart. I interpreted LOCKED as an errorstate.

Does the device driver error recovery on the i2c bus itself? For example when the slave pulls down SDA?

Thanks again for your help.

Regards
Michael
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C2 and SPI1 at the same time

Post by Giovanni »

Hi,

If I remember well there were issues with this I2C peripheral and under some condition the I2C bus can enter an unrecoverable state.
Barthess is the person who worked on this and may be he can be of help to you. Try a PM or the chibios IRC channel.

Giovanni
Post Reply