S32K IIC Communication Error Recovery

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S32K IIC Communication Error Recovery

跳至解决方案
2,546 次查看
qiu
Contributor I

I use S32k146 chip.

I make an I2C communication error (SDA ,SCL short circuit).When the circuit works normally. The iic driver can recover from the error,and it will not communicate with lcd slaver any more ,And the i2c don't work.

0 项奖励
回复
1 解答
2,523 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@qiu

Yes, you can take a look at UM10204

https://www.nxp.com/webapp/sps/download/preDownload.jsp?render=true 

Chapter:

3.1.16 Bus clear
In the unlikely event where the clock (SCL) is stuck LOW, the preferential procedure is
to reset the bus using the HW reset signal if your I2C devices have HW reset inputs. If
the I2C devices do not have HW reset inputs, cycle power to the devices to activate the
mandatory internal Power-On Reset (POR) circuit.

If the data line (SDA) is stuck LOW, the controller should send nine clock pulses. The
device that held the bus LOW should release it sometime within those nine clocks. If not,
then use the HW reset or cycle power to clear the bus.

 

you can try to set the SDA & SCL as GPIO ports, then wait for nine clocks, and then restore the two ports to I2C ports

detail you can refer to this :

https://www.nxp.com.cn/docs/en/application-note/AN4803.pdf 

page 18:

tI2C_fault I2C_Restore(void)
{
 unsigned char tmp = 0;
 I2C_STOP_SIGNAL;
 I2C_DeInit();
 I2C_MASTER_SDA_PIN_AS_GPIO;
 I2C_MASTER_SDA_PIN_GPIO_HIGH_DRIVE;
 I2C_MASTER_SCL_PIN_AS_GPIO;
 I2C_MASTER_SDA_PIN_AS_OUT;
 I2C_MASTER_SDA_PIN_0;
 I2C_MASTER_SCL_PIN_AS_OUT;
 for(tmp = 0; tmp <9; tmp ++) // nine clock for data
 {
 I2C_MASTER_SCL_PIN_0;
 I2C_delay();
 I2C_MASTER_SCL_PIN_1;
 I2C_delay();
 }
 I2C_MASTER_SCL_PIN_0;
 I2C_MASTER_SDA_PIN_AS_OUT; //SDA pin set to output
 I2C_MASTER_SDA_PIN_1; //negative acknowledge
 I2C_delay();
 I2C_MASTER_SCL_PIN_1;
 I2C_delay();
 I2C_MASTER_SCL_PIN_0;
 I2C_delay();
 I2C_MASTER_SDA_PIN_0; //stop
 I2C_delay();
 I2C_MASTER_SCL_PIN_1;
 I2C_delay();

 I2C_MASTER_SDA_PIN_AS_IN;

Hope this works for you.

 

在原帖中查看解决方案

3 回复数
2,537 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@qiu

Have you tried using an oscilloscope or logic analyzer to measure the SDA and SCL waveforms?

If there is no problem with the master's transmission, then you should check whether the slave device has special recovery steps.

 

0 项奖励
回复
2,535 次查看
qiu
Contributor I

Yes,i used oscilloscope to measure the SDA and SCL waveform,   and the master did not  transmit any thing.

Does the S32K I2C have any recovery mechanism?

0 项奖励
回复
2,524 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@qiu

Yes, you can take a look at UM10204

https://www.nxp.com/webapp/sps/download/preDownload.jsp?render=true 

Chapter:

3.1.16 Bus clear
In the unlikely event where the clock (SCL) is stuck LOW, the preferential procedure is
to reset the bus using the HW reset signal if your I2C devices have HW reset inputs. If
the I2C devices do not have HW reset inputs, cycle power to the devices to activate the
mandatory internal Power-On Reset (POR) circuit.

If the data line (SDA) is stuck LOW, the controller should send nine clock pulses. The
device that held the bus LOW should release it sometime within those nine clocks. If not,
then use the HW reset or cycle power to clear the bus.

 

you can try to set the SDA & SCL as GPIO ports, then wait for nine clocks, and then restore the two ports to I2C ports

detail you can refer to this :

https://www.nxp.com.cn/docs/en/application-note/AN4803.pdf 

page 18:

tI2C_fault I2C_Restore(void)
{
 unsigned char tmp = 0;
 I2C_STOP_SIGNAL;
 I2C_DeInit();
 I2C_MASTER_SDA_PIN_AS_GPIO;
 I2C_MASTER_SDA_PIN_GPIO_HIGH_DRIVE;
 I2C_MASTER_SCL_PIN_AS_GPIO;
 I2C_MASTER_SDA_PIN_AS_OUT;
 I2C_MASTER_SDA_PIN_0;
 I2C_MASTER_SCL_PIN_AS_OUT;
 for(tmp = 0; tmp <9; tmp ++) // nine clock for data
 {
 I2C_MASTER_SCL_PIN_0;
 I2C_delay();
 I2C_MASTER_SCL_PIN_1;
 I2C_delay();
 }
 I2C_MASTER_SCL_PIN_0;
 I2C_MASTER_SDA_PIN_AS_OUT; //SDA pin set to output
 I2C_MASTER_SDA_PIN_1; //negative acknowledge
 I2C_delay();
 I2C_MASTER_SCL_PIN_1;
 I2C_delay();
 I2C_MASTER_SCL_PIN_0;
 I2C_delay();
 I2C_MASTER_SDA_PIN_0; //stop
 I2C_delay();
 I2C_MASTER_SCL_PIN_1;
 I2C_delay();

 I2C_MASTER_SDA_PIN_AS_IN;

Hope this works for you.