LPC4078 I2C Bus gets stuck while Master Transfer

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

LPC4078 I2C Bus gets stuck while Master Transfer

928件の閲覧回数
mohsin_butt
Contributor II

Hello LPC Support,

I am having an issue with I2C communication using LPC4078 when bootloaded (see Note). LPC is set as master and is communicating with a temperature sensor (TMP75CIDGK). The problem occurs in event handler:

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) {} /*CODE STUCKS HERE*/
}

The I2C2 Status Register has a value of 0x8 which according to datasheet is start condition is sent, which is correct:

Screenshot (43).png

Screenshot (44).png

When the I2C bus is configured it is checked if the SCL and SDA is low, if yes then try to send dummy clocks on SCL to unlock it. But the code does not execute because SCL and SDA are high before and after initialization. The problem occurs when the data is sent using the API. The start condition is send when the transfer starts using Chip_I2C_MasterTransfer function:

/* Transmit and Receive data in master mode */
int Chip_I2C_MasterTransfer(I2C_ID_T id, I2C_XFER_T *xfer)
{
	struct i2c_interface *iic = &i2c[id];

	iic->mEvent(id, I2C_EVENT_LOCK);
	xfer->status = I2C_STATUS_BUSY;
	iic->mXfer = xfer;

	/* If slave xfer not in progress */
	if (!iic->sXfer) {
		startMasterXfer(iic->ip); /* Start condition set SCL = SDA = 0(low)*/
	}
	iic->mEvent(id, I2C_EVENT_WAIT); /* This function gets stuck */
	iic->mXfer = 0;

	/* Wait for stop condition to appear on bus */
	while (!isI2CBusFree(iic->ip)) {}

	/* Start slave if one is active */
	if (SLAVE_ACTIVE(iic)) {
		startSlaverXfer(iic->ip);
	}

	iic->mEvent(id, I2C_EVENT_UNLOCK);
	return (int) xfer->status;
}

Can someone please explain what exactly is the problem here?

Thanks in advance.

NOTE: The application is bootloaded from 0x48000. The same appliction when running without bootloading, from 0x00, it works without any issue.

0 件の賞賛
返信
4 返答(返信)

900件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

As you said that the issue happens only after the application is bootloaded via I2C, in the case, I suggest you reset the I2C0 module by setting then clearing the corresponding bit in the RESTCONO register in application code, which will isolate the bootloader configuration.

Hope it can help you

BR

XiangJun Rong

xiangjun_rong_0-1702017545826.png

I copy it from UM10562.pdf

0 件の賞賛
返信

892件の閲覧回数
mohsin_butt
Contributor II

Thanks for the reply.

Can you tell me if I should reset the I2C periphery before I2C pins configuration and initialization or after?

I am asking because in Bootloader the PINS are set to default configuration (IOCON_FUNC0 | IOCON_MODE_INACT) and only when the application starts, the pins are configured as I2C (IOCON_FUNC2 | IOCON_MODE_INACT | IOCON_OPENDRAIN_EN)

Thanks for your support.

0 件の賞賛
返信

846件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I think it is okay to reset the I2C module before or after you assign the I2C pins.

Hope it can help you

BR

XiangJun Rong

0 件の賞賛
返信

666件の閲覧回数
mohsin_butt
Contributor II

 

Hi XiangJun,

thanks for your reply. I tried to reset the I2C periphery before and after pin initilialization using the library function Chip_SYSCTL_PeriphReset(SYSCTL_RESET_I2C2) but it didn't change the behaviour. The problem is that the I2C2_IRQHandler is not being called after the START condition is set/sent as described above. The I2C2_IRQHandler calls handleMasterXferState to update the registers.

When I change the event handler in Chip_I2C_SetMasterEventHandler from Chip_I2C_EventHandler (interrupt based) to Chip_I2C_EventHandlerPolling (polling based) then the communication with temperature sensor is working without any issues.

Then question is why the interrupt handler is not being called, any suggestions?

0 件の賞賛
返信