[DONE] I2C driver for STM32F0

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
goeck
Posts: 92
Joined: Mon Feb 11, 2013 12:00 pm

Re: [DONE] I2C driver for STM32F0

Post by goeck »

Hey,

now using the new driver as well and having issues here. I have a STM32F0 Discovery connected to 4 of TMC222 motor motion controllers, which used to work fine with the I2Cv2 driver supplied earlier by doceme as a patch.
My point is, that if i use

Code: Select all

i2cMasterTransmitTimeout(&I2CD1, addr>>1, command, txLength, buffer, rxLength, MS2ST(10));
I get the adress byte thrown on the line and ACKed, then the command byte also ACKed but then the SCL line keeps low, the SDA line gets high. Seemes like an endlessly streeetched clock cycle. I found, some Cypress PSoC had same issues, see here: http://www.cypress.com/?id=4&rID=38929.
No STOP contition is generated and my slaves can't supply an answer on the sent intend.

Help is greatly appreciated.
Cheers
Stefan
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [DONE] I2C driver for STM32F0

Post by Giovanni »

Hi,

The only I2C device I can test on in this moment is an M24M01 EEPROM, whould be possible to simulate the problem using that?

Please post the parameter values for that transmit.

Giovanni
MartinP
Posts: 35
Joined: Mon Apr 02, 2012 11:54 am

Re: [DONE] I2C driver for STM32F0

Post by MartinP »

Hi Goeck,
Did you fix the missing DMA vectors?
in STM32F0xx\stm32_dma.c
you need to change the following:
Line 112: CH_IRQ_HANDLER(DMA1_Ch1_IRQHandler) --> CH_IRQ_HANDLER(Vector64)
Line 130: CH_IRQ_HANDLER(DMA1_Ch2_3_IRQHandler) --> CH_IRQ_HANDLER(Vector68)
Line 159: CH_IRQ_HANDLER(DMA1_Ch4_5_IRQHandler) --> CH_IRQ_HANDLER(Vector6C)

as the preprocessor definitions DMA1_Ch1_IRQHandler, DMA1_Ch2_3_IRQHandler, DMA1_Ch4_5_IRQHandler were deleted lately.

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

Re: [DONE] I2C driver for STM32F0

Post by Giovanni »

Hi,

BTW, tomorrow I will fix the problem with vectors. Couldn't do that during the week.

Giovanni
goeck
Posts: 92
Joined: Mon Feb 11, 2013 12:00 pm

Re: [DONE] I2C driver for STM32F0

Post by goeck »

Hey guys, sorry, no net connection during weekend. So here we go again. I saw the fix for bug #400, which adresses the DMA issue, right.
I didn't get any hints by the compiler or linker regarding interrupt vectors or similar...
Now I will try with the latest SVN code rev. 5591.

Also I found a screenshot laying around on my desktop which was generated by Saleae logic for the purpose of showing the result on the I2C lines.. hoping that this will disappear now, I still want to show off the behaviour I experienced last friday.

Thanks for the replies anyway.
Cheers

____EDIT1:
After using the mentioned SVN revision of code it freakin just works :-)
Thanks for alle the support again!

Keept it up.
Cheers
Stefan
Attachments
Saleae Logic screenshot
Saleae Logic screenshot
screenshot.png (35.19 KiB) Viewed 7799 times
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: [DONE] I2C driver for STM32F0

Post by steved »

In the course of finding some problems in my code, I had a closer look at some of the flow within the I2C driver. I'm not sufficiently familiar with the entrails of ChiboOS to say that there is definitely a problem, but there looked to be a couple of places where interrupts might cause some receive-related code to be executed twice. I've attached my modified driver in the hope that the experts might take a look.
Attachments
I2Cv2.zip
(7.36 KiB) Downloaded 534 times
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [DONE] I2C driver for STM32F0

Post by Giovanni »

Hi,

Thanks, there were some good points in the patch and I merged it, I also made some more changes. The driver appears to work stably and very well.

Just a not, please consider our coding conventions when submitting code http://www.chibios.org/dokuwiki/doku.ph ... tyle_guide this would make merging code easier.

Giovanni
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: [DONE] I2C driver for STM32F0

Post by DeusExMachina »

Hello,

I downloaded Chibios 2.6.2 version but I don't find i2c driver in ChibiOS_2.6.2\os\hal\platforms\STM32F0xx\
If drivers is stable, why it is absent in distribution?
goeck
Posts: 92
Joined: Mon Feb 11, 2013 12:00 pm

Re: [DONE] I2C driver for STM32F0

Post by goeck »

Well, I think it's located in os/platforms/STM32/I2Cv2.
I guess that's because those drivers are common to more than one platform (in this case STM32F0xx), Giovanni, is that true?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [DONE] I2C driver for STM32F0

Post by Giovanni »

Hi,

Correct, most driver are under ./os/hal/platforms/STM32 because are shared among the various sub-families.

Giovanni
Post Reply