No I2C Clock signal

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

No I2C Clock signal

874 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by g_mocken on Thu Jul 16 07:22:19 MST 2015
Hi,

I am trying to use I2C on LPC4074. Below is a rough sketch of my initialization, which I derived from the "periph_i2c" sample code (which is designed for LPC43xx, though):

void I2C0_IRQHandler(void) {
if (Chip_I2C_IsMasterActive(I2C0)) {
Chip_I2C_MasterStateHandler(I2C0);
}
else {
Chip_I2C_SlaveStateHandler(I2C0);
}
}

void test(void) {


Chip_IOCON_Init(LPC_IOCON);
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 30, IOCON_FUNC4 | IOCON_OPENDRAIN_EN);
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 31, IOCON_FUNC4 | IOCON_OPENDRAIN_EN);

Chip_I2C_Init(I2C0);
Chip_I2C_SetClockRate(I2C0, 400000);
Chip_I2C_SetMasterEventHandler(I2C0, Chip_I2C_EventHandler);
NVIC_ClearPendingIRQ(I2C0_IRQn);
NVIC_EnableIRQ(I2C0_IRQn);

static uint8_t buf[10];
static I2C_XFER_T xfer={.slaveAddr=I2C_ADDR_7BIT, .txBuff=buf, .txSz=sizeof(buf)};
Chip_I2C_MasterSend(I2C0, xfer.slaveAddr, xfer.txBuff, xfer.txSz);
}


When I single-step test() and put a scope on SDA and SCL, then I notice a high->low transition on SDA on the last line of the following LPCOpen function, which is called by Chip_I2C_MasterSend():

/* Enable I2C and start master transfer */
STATIC INLINE void startMasterXfer(LPC_I2C_T *pI2C)
{
/* Reset STA, STO, SI */
pI2C->CONCLR = I2C_CON_SI | I2C_CON_STO | I2C_CON_STA | I2C_CON_AA;

/* Enter to Master Transmitter mode */
pI2C->CONSET = I2C_CON_I2EN | I2C_CON_STA;
}


I would expect the clock line to show the same transition in order to make this a START condition, but SCL stays high, no interrupt trigers and the code hangs in Chip_I2C_EventHandler(), probably waiting for the START condition to complete.


Do you have any idea what could be wrong or missing in this setup?

Labels (1)
0 Kudos
Reply
3 Replies

691 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by g_mocken on Fri Jul 17 05:15:24 MST 2015
I think I have found the problem:

Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 30, IOCON_FUNC4 | IOCON_DIGMODE_EN | IOCON_OPENDRAIN_EN);
Chip_IOCON_PinMuxSet(LPC_IOCON, 1, 31, IOCON_FUNC4 | IOCON_DIGMODE_EN | IOCON_OPENDRAIN_EN);


The digital mode was unintentionally disabled. Explicitly enabling it helps.
0 Kudos
Reply

691 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by g_mocken on Thu Jul 16 08:49:40 MST 2015

Quote: nerd herd

Any particular reason why you are using the codebase for the LPC4300 series? I would start with the LPCOpen software examples for the EA LPC4088 board: ...



Thanks for pointing this out (I only have an LPCLink2 demo board, which is why I usually start with 4370 code before porting to my custom board with 4074). I quickly went through the 4088 code, and I think it is identical. It uses other pins, but that appears to be all.

Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 27, IOCON_FUNC1);
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 28, IOCON_FUNC1);


Since I have cannot change the design of the custom board, I cannot switch to those pins (Edit: they do not even exist for the 4074FBD80 used here), and I am still stuck with no clock signal (or with an incomplete START condition).
0 Kudos
Reply

691 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by nerd herd on Thu Jul 16 07:39:52 MST 2015
Hi g_mocken,

Any particular reason why you are using the codebase for the LPC4300 series? I would start with the LPCOpen software examples for the EA LPC4088 board:

https://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc40xx-packages
0 Kudos
Reply