[solved] Problem with I2C example from LPCopen with LPCXpresso 1769

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

[solved] Problem with I2C example from LPCopen with LPCXpresso 1769

1,408 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mos87 on Mon Apr 18 08:27:56 MST 2016
Hello,

im owning an LPCXpresso 1769 board and want to access the 24LC64 EEPROM who is also at the board.
The EEPROM is connected to I2C1 at the Pins P0.19 and P0.20.

How I see it I should be able too access the EEPROM via I2C without any hardware changes.

I was trying the run the periph_i2c example from the LPCopen V2.10 to learn how to use the lib.

In the example I disabled the initialization of I2C0 and the virtual Slaves and wanted to check all Bus devices with the i2c_probe_slaves() function.

static void i2c_probe_slaves(I2C_ID_T i2c)
{
int i;
uint8_t ch[2];

DEBUGOUT("Probing available I2C devices...\r\n");
DEBUGOUT("\r\n     00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
DEBUGOUT("\r\n====================================================");
for (i = 0; i <= 0x7F; i++) {
if (!(i & 0x0F)) DEBUGOUT("\r\n%02X  ", i >> 4);
if (i <= 7 || i > 0x78) {
DEBUGOUT("   ");
continue;
}
/* Address 0x48 points to LM75AIM device which needs 2 bytes be read */
if(Chip_I2C_MasterRead(i2c, i, ch, 1 + (i == 0x48)) > 0)
DEBUGOUT(" %02X", i);
else
DEBUGOUT(" --");
}
DEBUGOUT("\r\n");
}


The problem is now that at the Chip_I2C_MasterRead() the programm blocks and dont do anything.
The real blocking is little deeper in the Chip_I2C_EventHandler(). The status stay always at I2C_STATUS_BUSY.

void Chip_I2C_EventHandler(I2C_ID_T id, I2C_EVENT_T event)
{
struct i2c_interface *iic = &i2c[id];
volatile I2C_STATUS_T *stat;

/* Only WAIT event needs to be handled */
if (event != I2C_EVENT_WAIT) {
return;
}

stat = &iic->mXfer->status;
/* Wait for the status to change */
while (*stat == I2C_STATUS_BUSY) {}
}


Any ideas why the example code isnt working at me?
Are there any issues at the LPCopen I2C library?

Thanks for any informations
Labels (1)
0 Kudos
4 Replies

719 Views
lpcware
NXP Employee
NXP Employee
bump
0 Kudos

719 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by mos87 on Thu Apr 21 15:26:33 MST 2016
THANKS!!!!!!!!!!!

Now it is working. But why there is a known bug which is not fixed....
So i always have to look for bugs befor i can use some lpcopen driver ... not what i expected.

Thanks again for your help.
0 Kudos

719 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Thu Apr 21 08:01:27 MST 2016
Could be useful to read:

https://www.lpcware.com/content/forum/lpc1769-i2c-not-working
0 Kudos

719 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by drobe011 on Thu Apr 21 05:23:41 MST 2016
I believe I had a similar problem when I used to use the board support package.

Check the board.c file on lines 275 and 276 in the void Board_I2C_Init(I2C_ID_T id) function where it sets the pin function and mode.  It was incorrect (and still is).  It incorrectly sets the pins to Reserved.

275 and 276 should read:

Chip_IOCON_PinMux(LPC_IOCON, 0, 19, IOCON_MODE_INACT, IOCON_FUNC3);
Chip_IOCON_PinMux(LPC_IOCON, 0, 20, IOCON_MODE_INACT, IOCON_FUNC3);


Not:

Chip_IOCON_PinMux(LPC_IOCON, 0, 19, IOCON_MODE_INACT, IOCON_FUNC2);
Chip_IOCON_PinMux(LPC_IOCON, 0, 20, IOCON_MODE_INACT, IOCON_FUNC2);


You can check it out it the user manual (UM10360) page 117 in para 8.5.2

That was my problem anyways.


Dave
0 Kudos