Page 2 of 3
Re: STM32F4 I2C with DMA
Posted: Mon Feb 16, 2015 8:45 pm
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
Re: STM32F4 I2C with DMA
Posted: Mon Feb 16, 2015 9:55 pm
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
Re: STM32F4 I2C with DMA
Posted: Tue Feb 17, 2015 7:58 am
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.
Re: STM32F4 I2C with DMA
Posted: Tue Feb 17, 2015 8:33 am
by Giovanni
So you have to poll the device and wait that it stops NACKing your requests right?
Giovanni
Re: STM32F4 I2C with DMA
Posted: Tue Feb 17, 2015 9:03 am
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.
Re: STM32F4 I2C with DMA
Posted: Tue Feb 17, 2015 8:59 pm
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
Re: STM32F4 I2C with DMA
Posted: Tue Feb 17, 2015 10:03 pm
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?
Re: STM32F4 I2C with DMA
Posted: Tue Feb 17, 2015 10:11 pm
by Giovanni
v1 is for old I2C peripherals, v2 is for the new peripheral (STM32F0 and STM32F3).
Giovanni
Re: STM32F4 I2C with DMA
Posted: Wed Feb 18, 2015 2:19 am
by Rick Burnett
Ahh, okay, that makes sense. So the correct one is selected for the device I am using?
Re: STM32F4 I2C with DMA
Posted: Wed Feb 18, 2015 2:39 am
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?