This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2c master clock frequency setting

I am using the piccolo f28069  at 90Mhz.

I checked the CPU speed at the pin GPIO18 using the scope (got 22.4Mhz  with XCLKOUTDIV=0 ).

I configured the I2C slock to run at 400kbit/s    see  code below   but I got only 106kbit/s   measured with the scope !!!  

Any Idea  where can be the problem?

Thank you

Hamid

void I2CA_Init(void)
{
// Initialize I2C
I2caRegs.I2CSAR = I2C_SLAVE_ADDR; // Slave address

I2caRegs.I2CPSC.all = 8; // IPSC = 8 Prescaler - need 7-12 Mhz on module clk CLK module = 90/(8+1)= 10Mhz

//IPSC = 8
//Tmodul*[(ICLL+d)+(ICCH+d)]=Tmaster=400khz
// low periode = Tmod*(ICCL+d)
// High periode = Tmod*(ICCH+d)
//low periode > High periode (2 time appr)
//d=5 for IPSC >1

I2caRegs.I2CCLKL = 10; // NOTE: must be non zero
I2caRegs.I2CCLKH = 5; // NOTE: must be non zero

//I2caRegs.I2CIER.all = 0x24; // Enable SCD & ARDY interrupts
I2caRegs.I2CIER.all = 0x00; // disable all interrupts

I2caRegs.I2CMDR.all = 0x0020; // Take I2C out of reset
// Stop I2C when suspended

I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO
I2caRegs.I2CFFRX.all = 0x2040; // Enable RXFIFO, clear RXFFINT,

return;
}

  • I make it working  I had to keep the I2C module in RESET while programming the clock.

    but my system still not working :  I am trying to send 4 bytes using the FIFO mode  , after the 9 clock pulses the clock stay low , any help ? 

    Thank you for the support

    Hamid

    void I2CA_Write_power_supplies_New_voltage(void)
    {


    while((I2caRegs.I2CMDR.bit.STP == 1) || I2caRegs.I2CSTR.bit.BB == 1 ) ; //wait until the bus is not busy and STP bit is
    //cleared from any previous master communication.
    I2caRegs.I2CSAR = I2C_SLAVE_ADDR; //Set slave address
    I2caRegs.I2CCNT = I2C_NUMBYTES_TX; //Numbe rof bytes to transfer
    I2caRegs.I2CFFTX.all = 0x6000; //enable FIFO mode and reset TX FIFO
    I2caRegs.I2CDXR = 0x15; // first byte
    I2caRegs.I2CDXR = 0x45; // second byte
    I2caRegs.I2CDXR = 0xA; // 3rd byte
    I2caRegs.I2CDXR = 0xB; // fourth byte
    I2caRegs.I2CMDR.bit.TRX = 1; //Set to Transmit mode
    I2caRegs.I2CMDR.bit.MST = 1; //Set to Master mode
    I2caRegs.I2CMDR.bit.FREE = 1;//Run in FREE mode
    I2caRegs.I2CMDR.bit.STP = 1; // release the bus after Tx
    I2caRegs.I2CMDR.bit.STT = 1; //Send the start bit, transmission will follow
    }

  • I just attached the waveform 

    any help will be appriciated

    Thanks

    Hamid

  • Hamid,

    It looks like the data is getting NACKed. Do you have a slave connected?

    Please try setting STT and STP before you write the data.
  • Hi Adam,

    Thanks for getting back to me.

    Yes I have a Slave connected  and the problem was with the slave. Now it is working fine.

    Hamid