I2C sample code not generating INTR after start

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

I2C sample code not generating INTR after start

1,059件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by avass on Sat Feb 02 10:03:25 MST 2013
I wonder if any of you came across the same problem.
I hooked up my LIS331DL to my board in I2C mode.
I am running the I2C sample ( after changing the target address ).
SCL-SCL (pull-up), SDA-SDA (pull-up), SDO-GND, CS-GND

The I2CInit(comes back), but the I2CEngine hangs in waiting. I checked and there is no INTR at all.

I'm using the i2c sample. Your help is appreciated.

Thanks,

-A
0 件の賞賛
返信
3 返答(返信)

1,008件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by avass on Mon Feb 04 12:01:08 MST 2013
Thanks Rob, I found why there was no INTR, it was totally my fault ( as is most of the time ), my 3.3V power line had bad connection. Fixed that, now INTRs are coming in... Live and Learn...

I still have the Q though on finding the right values for the SCLL and SCLH. The 331DL spec says that it has to be at least 4.7 and 4.0 microsec accordingly. Assuming I am running at 12MHz on the 1115...

I know the formula of I2CFreq = PCLK / (SCLH + SCLL).
SCLH + SCLL = 12000kHz / 100 kHz = 120
This gives me about SCLL=65 and SCHH=56

Are these kinda OK?

Thx.
0 件の賞賛
返信

1,008件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by avass on Sun Feb 03 23:48:49 MST 2013

Quote: Rob65
Do you have some means of measuring the I2C lines?
Minimum is a voltmeter (or a logic probe) but a digital scope or logic analyzer is even better.



Yes, I have a 40MHz USB scope.


Quote: Rob65
Let's start with the configuration of your chip: SDO-GND, CS-GND is according to the datasheet placing the chip in I2C mode with A0 = 0.



Sorry, I think CS should be on Vdd, right? It is there now, my mistake in my original posting.


Quote: Rob65
Pull ups on SCL and SDA should indeed be there. I'm just wondering which board you are using and what the values of the pullups are (and are these connected to 3V3 ?)



I am using the LPCXpresso LPC1115 board connected to a STEVAL-MKI089V1 board with an LIS331DLH on it.

My current pull-ups were 2.4K. I have just lowered them to 1K but haven't tried it yet... I will eventually plan on running the system at 2.28V. What would be the proper values for both that and the 3.3V?


Quote: Rob65
I2CInit() always comes back.
I2CEngine() will always wait until the transaction has completed, the examples does not do proper error handling - I have no idea what happens when you try to send/read from a non-existing device.



It has an insanely long timeout.


Quote: Rob65
Still ... the interrupt should be triggered as soon as the start condition has been transmitted. But do take note that this only happens when the I2C peripheral can send a start condition. Meaning that both SCL and SDA need to be high first.



Yeah, I understand, but it's not happening. I'll check on the scope. If they don't go high, what could be the problem?


Quote: Rob65

Have you placed a breakpoint in the I2Cx_IRQHandler ? This is the interrupt routine that contains the real I2C engine to transmit data.



Yes, I also added global variables to all the status cases in the handler. There is absolutely no INTR coming in.


Quote: Rob65

Consider taking the improved I2C driver. The newest version is in my repository (i2c.c and i2c.h), an older version with a small piece of example code can be found here. (please consider using the first (newer) version, that contains some improvements and is the one I currently use).



Will give it a try fresh in the morning.

Also, what should be the numbers for I2SCLL_SCLL and I2SCLH_SCLH if I plan on going down to 12MHz on the 1115 and 400Hz updates from the 331?

Thank you!

Attila

PS: I like how the header of your i2c.c code says "pwm.c: Driver for PWM peripheral"  :-)
0 件の賞賛
返信

1,008件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Sun Feb 03 07:24:59 MST 2013
Do you have some means of measuring the I2C lines?
Minimum is a voltmeter (or a logic probe) but a digital scope or logic analyzer is even better.

Let's start with the configuration of your chip: SDO-GND, CS-GND is according to the datasheet placing the chip in I2C mode with A0 = 0.

Pull ups on SCL and SDA should indeed be there. I'm just wondering which board you are using and what the values of the pullups are (and are these connected to 3V3 ?)

I2CInit() always comes back.
I2CEngine() will always wait until the transaction has completed, the examples does not do proper error handling - I have no idea what happens when you try to send/read from a non-existing device.

Still ... the interrupt should be triggered as soon as the start condition has been transmitted. But do take note that this only happens when the I2C peripheral can send a start condition. Meaning that both SCL and SDA need to be high first.

Have you placed a breakpoint in the I2Cx_IRQHandler ? This is the interrupt routine that contains the real I2C engine to transmit data.

Consider taking the improved I2C driver. The newest version is in my repository (i2c.c and i2c.h), an older version with a small piece of example code can be found here. (please consider using the first (newer) version, that contains some improvements and is the one I currently use).

Rob

P.s: what kind of LPC1xxx processor are you using?
P.p.s: feel free to use other code from my repository.
0 件の賞賛
返信