Trouble using I2C on FRDM-KL25

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

Trouble using I2C on FRDM-KL25

ソリューションへジャンプ
2,246件の閲覧回数
funkyguy4000
Contributor II

Hello,

 

I have been agonizing over this simple I2C application for quite some time now and I could really use some help.  I have been following this guide for sometime: Tutorial: Accelerating the KL25Z Freedom Board | MCU on Eclipse

 

I am attempting to use I2C to communicate with the magnetometer side of an LSM303DLHC on the 9DOF from Adafruit. 
The board has resistors on the breakout so that isn't my issue.

My SDA and SCL lines are hooked up properly.

The I2C frequency is set just fine according to the workaround for the silicon error listed in the errata.

My device library and my PEimplementation are communicated between the generated code and everything else just fine.

 

One issue I'm getting is that for some reason, the I2C1_S register will have the busy flag set.

 

The general flow of things for reading the data registers on the magnetometer is as follows: "SimpleHeading()" -> "getMagX" -> "LSM303_ReadReg" -> "CI2C1_MasterSendBlock"  which will send the device address and the register address without a stop bit.  I will then call "CI2C1_MasterReceiveBlock" with a stop bit so that I'll be getting data back from the register and then ending the communication.  Btu for some reason the code generated by PE things that the bus is busy all the time.

 

I'm not sure exactly why this is happening but I can't fix it the code.  I have attached my project in an archive file. 
If somebody could look at it, I would greatly appreciate it.  I am literally on the edge of having a complete mental breakdown because of this thing.

Original Attachment has been moved to: I2C_PE.zip

0 件の賞賛
返信
1 解決策
1,600件の閲覧回数
BlackNight
NXP Employee
NXP Employee

In addition, you might check my project for the Pololu Zumo robot where I use the LSM303.

http://mcuoneclipse.com/2013/01/31/the-freedom-zumo-robot/

The project is on GitHub:

https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FRDM-KL25Z/Freedom_Zumo

I hope this helps,

Erich

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
1,600件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Have you checked your I2C SDA/SCL lines with a logic analyzer? There could be many things going wrong, including wrong wiring of the data/clock lines. At least this would give you insights what is going on with the bus. If the device reports that the bus is busy, then you should be able to see this in the logic analyzer if the device does not answer with an acknoledge.

But without having your hardware, it is very difficult to check and see what is going wrong on your end.

Erich

0 件の賞賛
返信
1,601件の閲覧回数
BlackNight
NXP Employee
NXP Employee

In addition, you might check my project for the Pololu Zumo robot where I use the LSM303.

http://mcuoneclipse.com/2013/01/31/the-freedom-zumo-robot/

The project is on GitHub:

https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FRDM-KL25Z/Freedom_Zumo

I hope this helps,

Erich

0 件の賞賛
返信
1,600件の閲覧回数
funkyguy4000
Contributor II

Thanks! I figured out my issue.  I was sending a pointer where it wasn't asking for it, whoops!
I've always been a fan of your tutorials and always recommend my peers to seek guides from there.  Keep up the good work!

0 件の賞賛
返信