STM32F4 I2C with DMA

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

Moderator: RoccoMarco

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

Re: STM32F4 I2C with DMA

Post by Giovanni »

I have no way to test the driver in those conditions, you could try to contact barthess who wrote the driver and has a lot more experience with I2C. He is often in the ChibiOS IRC channel too.

Giovanni
Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32F4 I2C with DMA

Post by Rick Burnett »

I'll try to contact him and see what I find out. I'll be sure to put the resolution to the problem here to help others.

Rick
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: STM32F4 I2C with DMA

Post by barthess »

Rick Burnett wrote:Interesting,

So the first call I do:

Code: Select all
status = i2cMasterTransmitTimeout(&I2CD1, NVRAM_ADDRESS, i2c_txbuf, 6, i2c_rxbuf, 0,tmo)



Generates no error. But, if I call this a second time, it will generate error 4, no (I2CD_ACK_FAILURE).

So then I added this before the second call:

Code: Select all
chThdSleep(1000);



And now it works. Is there something I need to call to block for me until the I2C is ready to work again?

It is how 24LC works (please read its datasheet). When you write some data it starts programming cycle and not acks until programming completed.
https://github.com/barthess/24aa here you can find some examples about such memory type.
Also, do NOT set R/W bit manually. It sets under the driver's hood.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 I2C with DMA

Post by Giovanni »

So you have to poll the device and wait that it stops NACKing your requests right?

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: STM32F4 I2C with DMA

Post by barthess »

Giovanni wrote:So you have to poll the device and wait that it stops NACKing your requests right?

Yes. Such procedure recommended by IC manufacturer for maximum write speed.
But you can just insert fixed sleep after write. Time amount is determined in datasheet too.
Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32F4 I2C with DMA

Post by Rick Burnett »

Interesting, no clue why this worked on another board without having to put any delay in-between? I'll take a look at your examples. Thanks for the information!! I really appreciate it.

Rick
Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32F4 I2C with DMA

Post by Rick Burnett »

One more question, looking through the ChibiOS directory structure and I see I2Cv1 and I2Cv2, is there somewhere that explains why two directories and what each contains?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 I2C with DMA

Post by Giovanni »

v1 is for old I2C peripherals, v2 is for the new peripheral (STM32F0 and STM32F3).

Giovanni
Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32F4 I2C with DMA

Post by Rick Burnett »

Ahh, okay, that makes sense. So the correct one is selected for the device I am using?
Rick Burnett
Posts: 150
Joined: Tue Jan 08, 2013 2:20 pm

Re: STM32F4 I2C with DMA

Post by Rick Burnett »

So let me ask another question, having actually finally read the data sheet, if I wanted to Poll for Ack, it seems to me that I would just put my second write into a loop where it would keep trying to write until it got an ACK back, in which case it would do the writing at that time because it could handle it?
Post Reply