S32K144: how to recover I2C slaver from error state based on AUTOSAR Mcal v1.0.2

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

S32K144: how to recover I2C slaver from error state based on AUTOSAR Mcal v1.0.2

1,057 Views
TysonHu
Contributor II

I use S32K1XX_MCAL4_3_RTM_1_0_2 package to develop a I2C slaver on S32K144.

I use Asynchronous Slave Transfer with Callbacks to configure "I2cSlaveTransmitCompleteNotification" and "I2cSlaveReceiveCompleteNotification".

In both of functions, I2c_StartListening() function is invoked to listen next I2C commander. 

However, if there was any error occurred on bus, I2c_LPI2C_pfSlaveStateOperation[] would always point to  I2c_LPI2C_SlaveError(). In this state, I2c_LPI2C_SlaveProcessAddress() would never be invoked. There is no chance to setup new I2C communication session .

I tried to add I2c_StartListening() in the error notification function. But it failed.

My question is that how to recover I2C slaver from error state? Any update of MCAL?

 

 

 

 

 

0 Kudos
5 Replies

1,035 Views
cuongnguyenphu
NXP Employee
NXP Employee

@TysonHu ,
I think "I2cSlaveTransmitCompleteNotification" and "I2cSlaveReceiveCompleteNotification" only be called when Data transmitted successfully, 
For error cases, I think you should enable error notification and add I2c_StartListening() in this function:

cuongnguyenphu_0-1656640517561.png

 

 

0 Kudos

1,029 Views
TysonHu
Contributor II

I agree with you about the handle of the error cases and that's what I have done.  However, the interface of error notification will only be called while FIFO error or Bit error occurs for slave mode.

In my case, I2C master intends to read data from slaver(S32K144 MCU). On the I2C bus, it's observed slave address and ACK bit are transmits correctly. But all the data  transmitted on the bus are 0xFF, which are not sent  by MCU. This is similar to the description:

https://www.i2c-bus.org/i2c-primer/analysing-obscure-problems/data-bytes-from-slave-are-0xff/ 

TysonHu_0-1656917014384.png

After this Read action, I2C master regards the transmission of this time has been finished. But the slaver still regards it not finished.  It can be observed I2c_LPI2C_au16SlaveCurrentIndex is still less than I2c_LPI2C_au16SlaveNumberOfBytes.

TysonHu_1-1656917588524.png

On the next time, the I2C master tries to write data to the slaver, the SDA and SCL are pulled down all the time. An I2C slaver interrupt is always triggered, function I2C_LPI2C_SlaveTransmit() also is always called whatever TDF is not set.  MCU falls into the trap of endless I2C slaver interrupt. Normal tasks cannot be executed any more.

TysonHu_2-1656919337161.png

I analyzed this is caused by the slaver is out of step with master. It is to be optimized to handle the mismatch of interrupt flags and the function pointer of I2c_LPI2C_pfSlaveStateOperation  in MCAL.

What I am confused is why the data are not really sent out by the slaver and why all data are 0xFF observed on I2C bus.

 

 

Tags (2)
0 Kudos

1,021 Views
cuongnguyenphu
NXP Employee
NXP Employee

@TysonHu ,
If I2C configuration is ok, the most reason for 0xff data is HW issue, when you connect SCL and SDA with incompatible resistor value. For S32K144 board, Pull up resistors of 4.7K each one connected between SDA and VDD and one connected between SCL and VDD. 
Can you check this again?

0 Kudos

1,018 Views
TysonHu
Contributor II

@cuongnguyenphu 

Thanks for your reply!

My colleague has tried to change both pull-up resistors of SDA and SCL from 1.5K to 4.7K. The error occurrence decreased. But it doesn't disappear completely.

I suspect  it may be improved to configure the parameters of Glitch Filter SCL/SDA or Data Valid  Delay, Clock Hold Time.

Are there any manual or application note to illustrate how to configure these parameters?

 

0 Kudos

1,009 Views
cuongnguyenphu
NXP Employee
NXP Employee

@TysonHu ,

Glitch Filter SCL/SDA or Data Valid  Delay, Clock Hold Time described in User Manual document of I2C module in your installation package (see eclipse\plugins\<I2C module>\doc\AUTOSAR_MCAL_I2C_UM.pdf)

These fields also describe in Reference Manual of S32K1 also. I can't find application notes that mention about how to configure these values out side of these documents


0 Kudos