Page 1 of 1

I2C2 and SPI1 at the same time

Posted: Tue Jan 21, 2014 6:36 pm
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

Re: I2C2 and SPI1 at the same time

Posted: Tue Jan 21, 2014 6:59 pm
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 421 times


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

Giovanni

Re: I2C2 and SPI1 at the same time

Posted: Tue Jan 21, 2014 9:37 pm
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

Re: I2C2 and SPI1 at the same time

Posted: Tue Jan 21, 2014 9:40 pm
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