Hi all,
I am encountering an issue with my I2C communication :
I am trying to TRANSMIT data in MASTER mode but my program stuck while waiting for IBSR[IBIF] to get set.
This is the code that I am using :
//Clear Interrupt Flag
pstIBSRReg = (TstDI2c_iIBSRBits *)(Ctu32DI2c_iBaseAdress[Fu16I2cLink] + Du32DI2c_iIBSROffset);
(* pstIBSRReg).u1IBIF = 1U;
//Make sure bus is idle -> IBB must be cleared
while (1U == (* pstIBSRReg).u1IBB) {}
//Generate start condition
pstIBCRReg = (TstDI2c_iIBCRBits *)(Ctu32DI2c_iBaseAdress[Fu16I2cLink] + Du32DI2c_iIBCROffset);
(* pstIBCRReg).u1TXRX = 1U; // Transmit
(* pstIBCRReg).u1MSSL = 1U; // Master Mode
//Wait for IBSR.IBB (bus busy) to be set
while (0U == (* pstIBSRReg).u1IBB) {}
//Put target address into IBDR
pstIBDRReg = (TstDI2c_iIBDRBits *)(Ctu32DI2c_iBaseAdress[Fu16I2cLink] + Du32DI2c_iIBDROffset);
(* pstIBDRReg).u8DATA = ((Fu8SlaveID<<1) | Du8DI2c_iWriteSlave);
// Wait for address transfer to be done
while (0U == (* pstIBSRReg).u1IBIF) {}
// Clear Interrupt Flag
(* pstIBSRReg).u1IBIF = 1U;
My program stuck at "while (0U == (* pstIBSRReg).u1IBIF) {}".
It is normal because the transfer was not initiated at all since that IBDR register value remains equal to 0x00.
Knowing that :
- START signal was correctly generated (verified with a scope).
- After generating the start signal and before writing into IBDR, I2C rgisters value are as below :
* IBCR = 0x30 // MDIS = 0 / MSSL = 1 / TXRX = 1
* IBSR = 0xA0 // TCF = 1 / IBB = 1
- I tried to write directly on the memory address 0xFFE30004 (IBDR address) but it still always equal to 0x00.
My question is what would forbid writing the IBDR register ?
Best regards,
Malek BEN.
Could it be that you run into a silicon errata problem with repeated start condition on I2C?
KL25Z and I2C: Missing Repeated Start Condition | MCU on Eclipse
Erich