Hello,
The start signal is not being generated on the I2C bus of MPC5XXX controller. There is no SDA high to low transition observed on the oscilloscope.
I have taken care about configuring the clock, enabling the I2C module, port settings( open drain, weak pull up ) etc that are required in the first place. I could see that the master and transmit bits are set inside the debugger.
Can someone help me find out what could be the reason for not getting a start condition ?
@David : Thank you for the sample code.
The controller is MPC5748G.
I already have these sample codes with me but my problem is something different and may be trivial.
I couldn't see any response from EEPROM slave(AT24256CN).
I had the SCL set up to 100Khz and i am at this stage of code where i am getting stuck up :
When i try to tap the SDA line through the oscilloscope, i don't see any high to low transition on it and this hints me that there is no actual start condition triggered and hence there is no slave address transmission or acknowledgement.
#define CTRL_WRITE 0xA0
while (I2C_0.IBSR.B.IBB==1){}; // while bus is busy, wait
I2C_0.IBCR.B.MS = 1; // Set transmit and master mode
I2C_0.IBCR.B.TX = 1; // And generate start condition
//===================START SIGNAL SENT===========================================
I2C_0.IBDR.R = CTRL_WRITE; // Send byte Control
while ((I2C_0.IBSR.B.IBIF==0)&&(timeout--)){};// Wait until IBIF or a timeout expires
I2C_0.IBSR.B.IBIF=1; // Clear the interrupt event flag
while(I2C_0.IBSR.B.RXAK==1){}; // Check for RXAK(ACKNOWLEDGE from Memory)
How do you have connected memory device? Do you have pull-up resistors on SCL/SDK lines? Could I see scheme of connection?
Hi,
Its working now, i could transmit. Its a port configuration issue.
But i have still an open point with receive operation.
As i have told you that i am using an ATMEL eeprom chip AT24C256N,
in receive mode, the IBDR starts showing valid data, like 0x1, 0x2..( i have earlier written 10 bytes of data ) but it continuously gets overwritten and then it ends at 0xFF, even before i go and perform a read operation on IBDR. How do i make it to receive byte by byte ? Also my receive operation is being triggered as soon as i set the I2c to receive mode at line number : 7 and not after dummy read operation at Line number : 8. All subsequent read operations are returning only 0xFF.
1. I2C_0.IBCR.B.RSTA = 1; // generate repeated START
2. I2C_0.IBDR.R = CTRL_READ; // Send byte Control
3. while ((I2C_0.IBSR.B.IBIF==0)&&(timeout--)){};// Wait until IBIF or a timeout expires
4. I2C_0.IBSR.B.IBIF=1; // Clear the interrupt event flag
5. while(I2C_0.IBSR.B.RXAK==1){}; // Check for RXAK(ACKNOWLEDGE from Memory)
6. //========================CONTROL BYTE SENT======================================
7. I2C_0.IBCR.B.TX = 0; //set for receive
8. dummy = I2C_0.IBDR.R; //initiates next byte data receiving
9. while ((I2C_0.IBSR.B.IBIF==0)&&(timeout--)){}; // Wait until IBIF;
10. I2C_0.IBSR.B.IBIF=1; // Clear the interrupt event flag;
11. while(I2C_0.IBSR.B.RXAK==1){}; // Check for RXAK(ACKNOWLEDGE from Memory)
12. if(nBytes>1)
13. {
14. while(i<(nBytes-1))
15. {
16. *(pData+i) = I2C_0.IBDR.R; //initiates next byte data receiving
17. while ((I2C_0.IBSR.B.IBIF==0)&&(timeout--)){}; // Wait until IBIF;
18. I2C_0.IBSR.B.IBIF=1; // Clear the interrupt event flag;
19. while(I2C_0.IBSR.B.RXAK==1){}; // Check for RXAK(ACKNOWLEDGE from Memory)
20. i++;
21. }
22. }
You don’t specify used MCU.
Anyway, I could point out following simple I2C driver written by my colleague:
https://community.nxp.com/docs/DOC-330972
Also as example of usage you can see my demo application:
https://community.nxp.com/docs/DOC-331807
Pin settings you may see in main file (function GPIO_Init).