I am using the LPC54606 processor and I have written code with an I2C bus on FLEXXOMM2 and it works perfectly.
I have since designed a new PCA (same LPC54606) where the I2C is now on the FLEXCOMM5 port and the I2C does not work and gets lost waiting for I2C.
I have turned off all other code and it still does not work. I then changed it back to FLEXCOMM2 and looked at the pins and the SCL pin and saw that it was trying to clock (the circuit is not designed to have I2C on that pin). So I know the code does work.
Does anybody have any ideas on what could be wrong?
#define I2C_MASTER_BASE ((I2C_Type *)I2C2_BASE)
#define I2C_MASTER_CLK_SRC kCLOCK_Flexcomm5
#define I2C_MASTER_CLK kFRO12M_to_FLEXCOMM5
void I2C_Init(ENUM_I2C_SPEED Speed)
{
i2c_master_config_t MasterConfig;
CLOCK_AttachClk(I2C_MASTER_CLK);
NVIC_SetPriority(IRQ_I2C, IRQ_PRIORITY_I2C);
// Change the default baudrate configuration
MasterConfig.enableMaster = true;
MasterConfig.baudRate_Bps = (uint32_t)Speed;
//MasterConfig.enableTimeout = true;
// Initialize the I2C master peripheral
I2C_MasterInit(I2C_MASTER_BASE, &MasterConfig, CLOCK_GetFreq(I2C_MASTER_CLK_SRC));
// Enable TimeOut
I2C_MASTER_BASE->CFG |= 0x8;
// Create the I2C handle for the non-blocking transfer
I2C_MasterTransferCreateHandle(I2C_MASTER_BASE, &m_I2C_Handle, I2C_Callback, NULL);
}
The base problem seems to be the "CLOCK_AttachClk"
Did you end up getting it working? I encounter the same issue.
Yes, paulsanders is right. How about it now after change it?
Regards,
Alice
Try changing #define I2C_MASTER_BASE ((I2C_Type *)I2C2_BASE)
For #define I2C_MASTER_BASE ((I2C_Type *)I2C5_BASE)
regards