S32K I2C Restore

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

S32K I2C Restore

1,671 Views
guys_fr
Contributor II

Hello,

I would like to known if a "Restore" can be produce by one of the I2C controller command ?

I refer to "AN4803" document and I2C_Restore() function. A "Start - Receive wDiscard - Stop" is not clocking the I2C bus. If its needed, it would be nice to have it in the SDK kit.

Thanks,

0 Kudos
4 Replies

1,485 Views
guys_fr
Contributor II

Hello Daniel,

Yes, this error is used by the "FLEXIO_I2C_DRV_MasterStartTransfer" but I am using the other driver. I will review the error in functions / IRQ. It will be a better way of handling it. Short term, I added a function that return the MSR / bus status that I process in IDLE. I try to restore/recover as an error correction on the I2C bus.

I will review the PLTF flag, I didn't get a PinLow condition yet, I notice that interrupt are more level than edges in the I2C controller which produce "oups".

Thanks, Guy.

0 Kudos

1,485 Views
guys_fr
Contributor II

Thanks,

Using DEBUG and break point, I easily ends up with SDA line lock down. The BBF bit stays to one forever. Its really not GPIO driver driven but it work and it unlock the I2C bus.I understand from your answer that the controller can't be force to "clock" the SCL line. I agree with the "user code" part but the driver need to be interrogated and return something like "I can't solve this one?".

#define I2C_MASTER_SDA_PIN_1 PTA-> PSOR |= 0x00000004
#define I2C_MASTER_SDA_PIN_0 PTA-> PCOR |= 0x00000004
#define I2C_MASTER_SCL_PIN_1 PTA-> PSOR |= 0x00000008
#define I2C_MASTER_SCL_PIN_0 PTA-> PCOR |= 0x00000008

#define I2C_MASTER_SDA_PIN_AS_IN (PTA-> PDDR = (PTA-> PDDR &(~(1U << 2))) | (0 << 2))
#define I2C_MASTER_SDA_PIN_AS_OUT (PTA-> PDDR = (PTA-> PDDR &(~(1U << 2))) | (1 << 2))

#define I2C_MASTER_SCL_PIN_AS_IN (PTA-> PDDR = (PTA-> PDDR &(~(1U << 3))) | (0 << 3))
#define I2C_MASTER_SCL_PIN_AS_OUT (PTA-> PDDR = (PTA-> PDDR &(~(1U << 3))) | (1 << 3))

#define I2C_MASTER_SDA_PIN_AS_GPIO PORTA-> PCR[2] = (PORTA-> PCR[2] &(~(PORT_PCR_MUX_MASK))) | PORT_PCR_MUX(PORT_MUX_AS_GPIO)
#define I2C_MASTER_SCL_PIN_AS_GPIO PORTA-> PCR[3] = (PORTA-> PCR[3] &(~(PORT_PCR_MUX_MASK))) | PORT_PCR_MUX(PORT_MUX_AS_GPIO)

#define I2C_MASTER_SDA_PIN_AS_I2C PORTA-> PCR[2] = (PORTA-> PCR[2] &(~(PORT_PCR_MUX_MASK))) | PORT_PCR_MUX(PORT_MUX_ALT3)
#define I2C_MASTER_SCL_PIN_AS_I2C PORTA-> PCR[3] = (PORTA-> PCR[3] &(~(PORT_PCR_MUX_MASK))) | PORT_PCR_MUX(PORT_MUX_ALT3)

#define I2C_MASTER_SDA_PIN_STATE (PTA-> PDIR &(1U << 2))

I do add this on all my I2C implementation.

0 Kudos

1,485 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Guy,

Do you mean that the LPI2C driver should return something like "I can't solve this one?" 

There are these error status codes:

pastedImage_1.png

You could check the SDA pin with Port Data Input Register (PDIR) when BUS_BUSY is returned.

And if SDA stays low, use the restore function. 

The LPI2C module supports configurable pin-stuck-low timeout. But this is not implemented in the LPI2C SDK driver.

This is complicated as the PLTF flag cannot be cleared as long as the pin low condition is present.  

pastedImage_2.png

BR, Daniel

0 Kudos

1,485 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello, 

The LPI2C module does not have any command that could be used.

And the LPI2C SDK driver does not control GPIOs.

The I2C pins are configured separately by the PIN driver.

If needed, the restore function can be implemented in the user code. 

Regards,

Daniel