LPC1769 EM I2C fast mode

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

LPC1769 EM I2C fast mode

355 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Wed May 25 08:05:37 MST 2011
Hello Forum users,

I want to use fast I2C for my sensor readings.
I first used the I2C2 port, i did not have any problems at all.

To use fast I2C i need to use I2C0, on port 0_27 and 0_28.
Changed the settings i needed to change.
Started the program and now i am getting an HardFault_Handler.
Tried to switch back to I2C2 but i am getting the error again :(

I am using the example project i2c.
The problem lies in this line:
I2CMasterState[portNum] = I2C_BUSY;

portNum = 0, i use i2c0.
I hope you can help me with this problem.
Using 3k3 resistors.
Embedded artist board.
0 Kudos
6 Replies

322 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Wed May 25 09:35:36 MST 2011
Yes i know what an array was.
I know understand.
0 Kudos

322 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 25 09:34:03 MST 2011
Do you know what an array is?

LPC_I2C[I2C_PORT_NUM] is an array with I2C_PORT_NUM (= 3) elements.

So you can use expressions like I2CMasterState[portNum] in I2CEngine(uint32_t portNum) to read/write from I2C0 to I2C2 with portNum from 0 to 2.

And if you use a wrong portNum there, you are trying to work with an unpowered (see PCONP...) I2Cx or wrong buffer, which results in HardFault :mad:
0 Kudos

322 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Wed May 25 09:14:13 MST 2011
I do not 100% understand what you mean.
Could you please explain it to me?
0 Kudos

322 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 25 09:12:05 MST 2011
i2c.h:
#define I2C_PORT_NUM        3
static LPC_I2C_TypeDef (* const LPC_I2C[I2C_PORT_NUM]) = { LPC_I2C0, LPC_I2C1, LPC_I2C2 };
So I2C_PORT_NUM is not the actual / used port, it's used to enumerate I2C ports.
0 Kudos

322 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Lithium on Wed May 25 09:01:36 MST 2011
Yes, i am using the example functions.
LPC_SC->PCONP |= (1 << 7);

I got it working but it's an dirty way.
Defined i2c port num to 3, and used my own port var set to 0.
0 Kudos

322 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed May 25 08:59:41 MST 2011
PCONP bit set?
0 Kudos