Hi,
I am having a problem changing the PIN mux at run time after the PIN was already configured.
I currently have a PIN setup iin I2C mux configuration. This pin is used for the SDA signal for I2C.
I need to switch this pin over to GPIO mode to control it. I don't have any other option because the I2C chip I am working with has a very special wake sequence with a very specific timing.
I have tried setting up the PIN in GPIO mode after configuring but I get a hard fault after trying to write to the PCOR register. Please see the code snippet below with comments. Please let me know how to do this.
I am using the mcuXpresso 2.4 SDK driver. See the code snippet below.
Additional information
- The I2C peripheral is setup in DMA mode with interrupts.
- I do not call I2C_MasterDeinit() or destroy of the I2C EDMA handles
- I am hoping i do not need to do this as all I want to do is switch the PIN mux over to GPIO and control the line temporary for a few micro seconds.
PORT_SetPinMux(i2c0_sda_pin.port, i2c0_sda_pin.pin, kPORT_MuxAsGpio);
port_pin_config_t pin_mux1_adv_config0 =
{
.pullSelect = kPORT_PullUp,
.slewRate = kPORT_FastSlewRate,
.passiveFilterEnable = kPORT_PassiveFilterEnable,
.openDrainEnable = kPORT_OpenDrainDisable,
.driveStrength = kPORT_HighDriveStrength,
.mux = kPORT_MuxAsGpio,
.lockRegister = kPORT_UnlockRegister
};
PORT_SetPinConfig(i2c0_sda_pin.port, i2c0_sda_pin.pin, &pin_mux1_adv_config0);
const gpio_pin_config_t gpio_output_default_low =
{
.pinDirection = kGPIO_DigitalOutput,
.outputLogic = 0u
};
GPIO_PinInit(i2c0_sda_pin.bank, i2c0_sda_pin.pin, &gpio_output_default_low);