i2c Slave issue on KL25Z

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

i2c Slave issue on KL25Z

ソリューションへジャンプ
2,720件の閲覧回数
jvr
Contributor I

Hello,

I have a KL25Z that I've been learning on.  I've recently started to work on making the board an i2c slave hooked up to a raspberry pi.  The pi i2c bus operates at 3.3v and has 1.8k pullups.  In Processor Expert I added an I2C_LDD component and set the following parameters:

I2C Channel: I2C1

Interrupt Service: enabled

Mode Selection: SLAVE

Address Mode: 7-bit

Slave address: 9

SDA Pin: PTE0

SCL Pin: PTE1

Enabled in init code: yes

Auto initlization: no

I also configured the bus for 100khz (pi default) by following the directions at KL25Z and I2C: Missing Repeated Start Condition | MCU on Eclipse to avoid the pre-scaler issue.  I left all other parameters at their defaults.  After generating code I added the i2c _Init function to main() in ProcessorExpert.c, compiled and loaded the code onto the board.

Once loaded and hooked up to the i2c bus I ran i2cdetect on the pi and, instead of a device being listed at address 9, I see devices listed at nearly every address on the bus:

root@pi-1:~# i2cdetect -y 1

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          03 04 05 06 07 08 -- -- -- 0c 0d 0e 0f

10: 10 11 12 13 14 15 -- -- -- -- 1a -- -- -- 1e 1f

20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e --

30: 30 -- -- 33 -- 35 36 37 38 39 3a 3b 3c 3d 3e 3f

40: 40 41 42 43 44 45 46 47 48 -- -- -- -- 4d -- --

50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e --

60: -- 61 -- -- -- 65 66 67 -- 69 6a 6b 6c 6d 6e 6f

70: 70 71 -- 73 74 75 76 --

root@pi-1:~#


Different runs show different addresses used.  As a sanity check I took an arduino that I already had running i2c code on and hooked it up to the bus (after removing the KL25Z).  It showed up at the expected address and nothing else was listed on the bus.

I've been poring over documentation and searching through these forums but I haven't seen anything that would point me in the right direction.  Is there something I'm missing that someone can point me to?  Or is this is a bug?

タグ(1)
0 件の賞賛
返信
1 解決策
1,466件の閲覧回数
jvr
Contributor I

Ok, here is the issue.  The cardboard inset that comes with the KL25 has a photo diagram of the board with the pins marked, which is what I have been working off of.  On that diagram, on figure2 where the pins are marked, PTE0 and PTE1 are reversed.  After your test program gave bad results I decided to check my soldering job on the pin headers by throwing together a quick LED blink test and testing each pin.  Sure enough I found them reversed.  With the wires flipped i2c behaves as expected.

In hindsight that should have been obvious, an Arduino UNO's SDA and SCL pins match the correct layout for those two pins.

元の投稿で解決策を見る

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

Hello,


I have tried I2C slave communication between Raspberry Pi (model B) and FREEDOM board - KL25Z.
My communication by master I2C0 (I don't have for I2C1 channel right S5 connector) was right.
To I2C0-master(raspi) is connected only one I2C slave device with 0x09 address:


pi@raspberrypi:~$ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- 09 -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspberrypi:~$ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- 09 -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
pi@raspberrypi:~$


Could you please check connection between raspi and KL25?

KL25                    -> RasPi
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I2C1_SDA(PTE0) -> SDA0(P1 - pin 3)
I2C1_SCL(PTE1) -> SCL0(P1 - pin 5)
                    GND -> GND (P1 - pin 6)


My test projects is attached.

Best Regards,
Jiri Rezler

1,467件の閲覧回数
jvr
Contributor I

Ok, here is the issue.  The cardboard inset that comes with the KL25 has a photo diagram of the board with the pins marked, which is what I have been working off of.  On that diagram, on figure2 where the pins are marked, PTE0 and PTE1 are reversed.  After your test program gave bad results I decided to check my soldering job on the pin headers by throwing together a quick LED blink test and testing each pin.  Sure enough I found them reversed.  With the wires flipped i2c behaves as expected.

In hindsight that should have been obvious, an Arduino UNO's SDA and SCL pins match the correct layout for those two pins.

0 件の賞賛
返信
1,466件の閲覧回数
JimDon
Senior Contributor III

My first guess would be incorrect hardware connection, as the symptoms suggest talking "thin air" as in  "noise", but that is just a wild guess. Which turns out is 100% correct.