lpcware

Interference of I2C to UART and GPIO LPC824

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 18, 2016 by lpcware
Content originally posted in LPCWare by Softface on Sun May 22 08:29:11 MST 2016
I made a program onLPC824 which use UART, SPI and different IO lines and I want to implement a drivers for I2C ADC converter.
When I use I2C (from periph_i2cm_interrup) alone I can address my ADC without any trouble but when in insert this piece of code in my program all other functionalities failed (UART,SPI, IO).
After many tries I find that the problem come from the function Chip_SWM_EnableFixedPin
static void Init_I2C_PinMux(void)
{
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);

Chip_SWM_IsEnabled(SWM_FIXED_I2C0_SDA);// Ligne X
Chip_SWM_IsEnabled(SWM_FIXED_I2C0_SCL);// Ligne Y

Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);
}

The worse is that after launching this init function it is no longer possible to recovery a proper functioning of (UART,SPI, IO).even if I launched again their initialization phase or disable the I2C fixed pin.
I have to suppress the Init_I2C_PinMux () and restart my program from LPCXpresso interface. After every port communication are restored.
Another strange affair I tried this the following piece of code. I can’t understand why the function do not return the expected result. Of course I tried to to enable and disable the periph CLOCK ibetween each tried with the same the same. At this stage my conclusion is that as soon as you use Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SDA); it become impossible to use another IO port. But I’m sure this conclusion is wrong. Anyone else have had this problem?
static void Init_I2C_PinMux(void)
{
uint32_ttmp=0;
/* Enable the clock to the Switch Matrix */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);

tmp = Chip_SWM_IsEnabled(SWM_FIXED_I2C0_SDA); // OK tmp = 0
tmp = Chip_SWM_IsEnabled(SWM_FIXED_I2C0_SCL); // OK tmp = 0

Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SDA);
Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SCL);

tmp = Chip_SWM_IsEnabled(SWM_FIXED_I2C0_SDA); // OK tmp = 1
tmp = Chip_SWM_IsEnabled(SWM_FIXED_I2C0_SCL); // OK tmp = 1

Chip_SWM_DisableFixedPin(SWM_FIXED_I2C0_SDA);
Chip_SWM_DisableFixedPin(SWM_FIXED_I2C0_SCL);

tmp = Chip_SWM_IsEnabled(SWM_FIXED_I2C0_SDA); // NOK tmp = 1 ?????
tmp = Chip_SWM_IsEnabled(SWM_FIXED_I2C0_SCL); // OK tmp = 0
Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);

}
I use LPCXpresso v8.0.0 [Build 526] [2015-11-23]

Outcomes