AnsweredAssumed Answered

MPC5748G_I2C module

Question asked by HU Qiang on Apr 26, 2016
Latest reply on May 4, 2016 by HU Qiang

When I initial the I2C module, I run the program step by step, observe the I2C registers.

     I notice that the "I2C_2.IBCR.B.MSSL" bit is always 0 and "I2C_2.IBDR.R" is also always 0.

     When I run the code "I2C_2.IBCR.B.MSSL = 1;", why will bit "I2C_2.IBSR.B.IBIF" and "I2C_2.IBSR.B.IBAL" turn to 1? instead of bit ""I2C_2.IBCR.B.MSSL" turn to 1?

     Is it that I cannnot select master mode, so I cannot set the "I2C_2.IBDR.R"?

 

 

void I2C_2_Init(void)

{

    // I2C Bus Frequency Divider Register (I2C_IBFD)

    I2C_2.IBFD.B.IBC = 0x20; // Division ratio to obtain SCL frequency from Platform clock/2.

 

 

    // I2C Bus Control Register (I2C_IBCR)

    I2C_2.IBCR.B.MDIS = 0; // Enable I2C module

 

 

    I2C_2.IBCR.B.IBIE = 1; // Interrupts from the I2C Bus module are enabled

    I2C_2.IBCR.B.TXRX = 1; // Transmit Mode

 

 

    // Start I2C master mode transmit

    I2C_2.IBCR.B.MSSL = 1; // Master Mode - When this bit is changed from 0 to 1, a START signal is generated on the bus and the master mode is selected

 

 

    I2C_2.IBSR.B.IBIF = 0; // I-Bus Interrupt Flag

    I2C_2.IBDR.R = 0x55; // Sent out 0x55

 

 

    // Observe changes in IBSR[TCF]

//    while (I2C_0.IBSR.B.TCF == 0);

 

 

    //Wait until IBSR[IBIF] = 1.

    while(I2C_2.IBSR.B.IBIF == 0);

 

 

    I2C_2.IBCR.B.MSSL = 0;       // Generate stop signal;

}

Original Attachment has been moved to: I2C_Z4_1.zip

Outcomes