AnsweredAssumed Answered

How to use both of I2C and SPI in LPC54101

Question asked by Takafumi Sugimoto on Sep 27, 2016
Latest reply on Oct 13, 2016 by Takafumi Sugimoto

Hi

 

I would like to use both of the I2C and the SPI on LPC54101.
However, happen an error on use SPI when I2C was initialized.
Do you know the measures?

 

When you use this code

ROM_I2CS_Init(devMemI2C, &i2csInit);

 

mXfer.status is ERR_SPI_BASE on endress.

ROM_SPIM_Transfer(spimHandle, &mXfer);

while (mXfer.status == ERR_SPI_BUSY) {}

 

This is code

SystemCoreClockUpdate();

 

Init_SPI_PinMux();

Init_I2C_PinMux();

Chip_Clock_EnablePeriphClock(LPC_SPIM_CLOCK);

Chip_SYSCON_PeriphReset(LPC_SPIM_RESET);

Chip_Clock_EnablePeriphClock(LPC_I2CS_CLOCK);

Chip_SYSCON_PeriphReset(LPC_I2CS_RESET);

 

Board_Init();

...

spimHandle = ROM_SPIM_Init(devMem, &spimInit);

if (ROM_SPIM_SetupTransfer(spimHandle, &spimConfig) != LPC_OK) {

}

 

NVIC_EnableIRQ(LPC_SPIIRQNUM);

...

i2csHandle = ROM_I2CS_Init(devMemI2C, &i2csInit);   // If this line does not exists, program will not happen error.

 

ROM_I2CS_SetupSlave(i2csHandle, &slaveSetup); // If does not exists it, you should comment out of this line

...

optimalDevI2C = Chip_Clock_GetAsyncSyscon_ClockRate() / 4000000;

LPC_I2C_PORT->CLKDIV = optimalDevI2C;

...

NVIC_EnableIRQ(LPC_I2CS_INT);

 

Outcomes