I2C re-init issues

cancel
Showing results for 
Search instead for 
Did you mean: 

I2C re-init issues

Jump to solution
321 Views
mspenard603
Contributor IV

Hi,

 Occasionally my I2C bus (running as the master) locks up. And so I try and re-initialized it. I can see the slave let go and SDA and SCL go high. So then I try and re-init by setting the lines up as GPIO. But I'm unable to bit-bang them high or low. I have the following while(1) setup, and yet on my scope the lines are non-response. What else can I do?


LPI2C_MasterDeinit(PPSYS_I2C_MASTER);

while(1)
{
delay_ms(10*1000);

ppPRINTF(DEBUG_CONSOLE_MODE_ERROR, "PPSYS_BSP_I2C4 RE-INIT GO");
IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_12_LPI2C4_SCL, 0U);
IOMUXC_SetPinMux( IOMUXC_GPIO_AD_B0_13_LPI2C4_SDA, 0U);

IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_12_LPI2C4_SCL, 0x10B0U);
IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_13_LPI2C4_SDA, 0x10B0U);


gpio_pin_config_t scl_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};
gpio_pin_config_t sda_config = {kGPIO_DigitalInput, 0, kGPIO_NoIntmode};
GPIO_PinInit(LPI2C4_GPIO, LPI2C4_GPIO_SCL_PIN, &scl_config);
GPIO_PinInit(LPI2C4_GPIO, LPI2C4_GPIO_SDA_PIN, &sda_config);

for(uint8_t i=0; i<12;i++)
{
GPIO_PinWrite(LPI2C4_GPIO, LPI2C4_GPIO_SCL_PIN, 0U);
delay_us(125);
GPIO_PinWrite(LPI2C4_GPIO, LPI2C4_GPIO_SCL_PIN, 1U);
delay_us(125);
}
GPIO_PinWrite(LPI2C4_GPIO, LPI2C4_GPIO_SCL_PIN, 0U);
delay_ms(1000);
GPIO_PinWrite(LPI2C4_GPIO, LPI2C4_GPIO_SCL_PIN, 1U);
}

0 Kudos
1 Solution
311 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi mspenard603,

    Do you want to use the IOMUXC_GPIO_AD_B0_12_LPI2C4_SCL and IOMUXC_GPIO_AD_B0_13_LPI2C4_SDA pin as the GPIO pin, then control the high and low, but you can't realize it?

   If yes, you need to configure the related pins as the GPIO at first:

   In the IOMUXC_SetPinMux and IOMUXC_SetPinConfig, you need to use IOMUXC_GPIO_AD_B0_12_GPIO1_IO12 and IOMUXC_GPIO_AD_B0_13_GPIO1_IO13.

  Then control the GPIO1_IO12 and GPIO1_13.

Please try it again.

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

View solution in original post

0 Kudos
1 Reply
312 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi mspenard603,

    Do you want to use the IOMUXC_GPIO_AD_B0_12_LPI2C4_SCL and IOMUXC_GPIO_AD_B0_13_LPI2C4_SDA pin as the GPIO pin, then control the high and low, but you can't realize it?

   If yes, you need to configure the related pins as the GPIO at first:

   In the IOMUXC_SetPinMux and IOMUXC_SetPinConfig, you need to use IOMUXC_GPIO_AD_B0_12_GPIO1_IO12 and IOMUXC_GPIO_AD_B0_13_GPIO1_IO13.

  Then control the GPIO1_IO12 and GPIO1_13.

Please try it again.

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

View solution in original post

0 Kudos