I2C1 on K64F - not working

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

I2C1 on K64F - not working

1,130 Views
davidatkins
Contributor I

Tryignt o sue the I2C1 port of a K64F, have been able to toggle the pins using GPIO mode to prove that they are connected,

When I try and use the standrad library code it gets stuck at waiting for the followign code

while (!(base->S & kI2C_IntPendingFlag))
{
}

both SCL and SDA remain high which suggest that its not driving the I2C lines onto the pins, trying to use PTC10/11 pins.

the config tool generatyed the followign code for the pins
/* PORTC10 (pin 82) is configured as I2C1_SCL */
PORT_SetPinMux(PORTC, 10U, kPORT_MuxAlt5);

PORTC->PCR[10] = ((PORTC->PCR[10] &
/* Mask bits to zero which are setting */
(~(PORT_PCR_PS_MASK | PORT_PCR_PE_MASK | PORT_PCR_ODE_MASK | PORT_PCR_ISF_MASK)))

/* Pull Select: Internal pullup resistor is enabled on the corresponding pin, if the
* corresponding PE field is set. */
| (uint32_t)(kPORT_PullUp)

/* Open Drain Enable: Open drain output is enabled on the corresponding pin, if the pin is
* configured as a digital output. */
| PORT_PCR_ODE(kPORT_OpenDrainEnable));

/* PORTC11 (pin 83) is configured as I2C1_SDA */
PORT_SetPinMux(PORTC, 11U, kPORT_MuxAlt5);

PORTC->PCR[11] = ((PORTC->PCR[11] &
/* Mask bits to zero which are setting */
(~(PORT_PCR_PS_MASK | PORT_PCR_PE_MASK | PORT_PCR_ODE_MASK | PORT_PCR_ISF_MASK)))

/* Pull Select: Internal pullup resistor is enabled on the corresponding pin, if the
* corresponding PE field is set. */
| (uint32_t)(kPORT_PullUp)

/* Open Drain Enable: Open drain output is enabled on the corresponding pin, if the pin is
* configured as a digital output. */
| PORT_PCR_ODE(kPORT_OpenDrainEnable));

Any ideas?

David

0 Kudos
4 Replies

768 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi david,

Would you please tell us which MCUXpresso Config Tools are you using?

I am using online and offline MCUXpresso Config Tools, both of them can generate correct codes.

PORT_SetPinMux(PORTC, 11U, kPORT_MuxAlt2);

MCUXpresso Config Tools offline.png

MCUXpresso Config Tools online.png

The i2c interrupt in SDK_2.3.0_FRDM-K64F also generate correct codes.

PTC10 PTC11 I2C1.PNG

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

768 Views
davidatkins
Contributor I

Hi,

Using the offline tools, is there a working example of working I2C1 port anywhere, I’m sure it’s going to be a config issues but the config tool does not generate the same code for I2C1 as it does I2C0, the i2c init function is not crated for example.

I have implemented a GPIO bit bang i2c using the pins and that works but is slow, so the circuity looks ok just the software side I think

David

0 Kudos

768 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Please download the  SDK_2.3.0_FRDM-K64F package refer Generating a downloadable MCUXpresso SDK v.2 package.

And then you can find the i2c interrupt example in it's folder. (For example: C:\SDK_2.3.0_FRDM-K64F\boards\frdmk64f\driver_examples\i2c\interrupt)

The example is configured 2 instances I2C , one as I2C master , another as I2C slave.

I2C0 I2C1 K64.PNG

I2C1 slave.PNG

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

768 Views
davidatkins
Contributor I

It seems that the PORTC I2C1 pins are configured as muxalt2 not muxalt5, this is from looking at the outptu of the config tool, nto sure which is correct now.

0 Kudos