LPCXpresso simple I2C example HELP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPCXpresso simple I2C example HELP

1,510 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Kaare on Thu Aug 30 15:24:30 MST 2012
Hi

I am trying to hook up two LPCXpresso boards for a simple I2C test.
Step 1 is to make a Master and a Slave, and let Master write/read some data from the slave.
There are complete examples for this on the LPCXpresso site.
They compile fine, but it does not work.

When debugging, I see that I never get a single interrupt.
Interrupt seems to be OK enabled.

What seems strange though, is when I enable the I2C:

[SIZE=2][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][SIZE=2]
LPC_I2C->CONSET = I2CONSET_I2EN;

[SIZE=3][COLOR=black]Then the bit for enable is set in both I2C0CONSET and -CLR registers.[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000]The same thing happens when i will make a START:[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][/COLOR][/SIZE]
LPC_I2C->CONSET = I2CONSET_STA;

[SIZE=3][COLOR=black]Then both the enable and clear bit in both registers are set.[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000]Why is this happening?[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000]Then it is both set and cleared at the same time... not good I think.[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000]Who wins the: the CLR or the SET?[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000]Does anyone have a clue if this is good or bad?[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000]I am using the examples as-is, in LPCXpresso IDE.[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000]LPC1343 as Master board.[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000]Thanks in advance[/COLOR][/SIZE]
[SIZE=3][COLOR=#000000]Kåre[/COLOR][/SIZE][/SIZE][SIZE=2][/SIZE]
[SIZE=2][/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE]
0 Kudos
Reply
5 Replies

1,288 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Kaare on Tue Sep 04 03:24:51 MST 2012
Seems to work now!
The problem is that the example is extremely simple, and I have to powercycle for each test, as the program just ends in a while(1)...

br
Kåre
0 Kudos
Reply

1,288 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Kaare on Mon Sep 03 23:44:33 MST 2012
Yes, it's the CONCLR register :o)

I don't read the register in the source.
I use the register viewer in the IDE. But if the register simply can't be read, this will also not be possible.
I remember this problem with ARM7 and another IDE.

Maybe this is not a problem then.

So the problem is still, why the NXP example does not work: I can't figure out why I dont get an interrupt after a START condition is started.
br
Kaare
0 Kudos
Reply

1,288 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Fri Aug 31 01:29:15 MST 2012
What is the CONRST register you are referring to? I can't see any reference to it in the User Manual. If you meant to say CONCLR that is a write-only register so you shouldn't try to make any sense out of any value that you have read from it.
0 Kudos
Reply

1,288 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Kaare on Fri Aug 31 00:55:38 MST 2012
Hi

This is not true:
The CON register is controlled by a Reset and a Set register (CONSET, CONRST).
Writing a 1 to a bit wil set/reset the bit in the CON register.
Writing a 0 does nothing. The example is therefore OK.

My problem is that when I set a 1 in CONSET, the same bit is set in the CONRST register, and this makes no sense to me.

And do I have to set the bit to 0 again manually?

br
Kåre
0 Kudos
Reply

1,288 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CroesJeroen on Thu Aug 30 15:38:09 MST 2012
I would use in stead of :
LPC_I2C->CONSET = I2CONSET_I2EN;


->
LPC_I2C->CONSET |= I2CONSET_I2EN;


also for the start. Otherwise youre setting the start bit and disabling the I2C module.

Youre doing an assignment to the register but set all bits to 0 except the ones you defined with I2EN and STA. You have to do an or to not change the value of the other bits.
0 Kudos
Reply