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 not getting started on TMS320F28033



My application uses SPI, SCI and I2c ports on the 28033

I have the SPI and SCI ports working fine, but cannot seem to get the I2c (which I thought would be the simplest) to talk to 24LC256EEPROM.

I have a scope attached and have not seen any activity on SCL  I believe that my clocking and setup agree with the TI example, so I am puzzled by the complete lack of a clock l on the SCL pin?!  I2CAENCLK is enabled, is there something here I missed?

Thanks,

Joe

  • Hi Joe, After you setup your I2C, you can try the following code to see if you pick up anything on the scope. Ive used this code to check bus activity and eeprom functionality.

     

    // Capture bus and see SCL  on scope

    // This code fills the first 64K of your eeprom with 0x55 and you should be able to see it on the scope.

    // Once the Master captures the I2C bus, the SCL line is held LOW.

    // No activity on the bus till it actually starts transmitting the start bit and address.

    //Mode -Master Transmitter, Repeat mode, Single Start, !!!NO STOP BIT!!!, Master will hold bus indefinitely until a reset is issued or the loop hits

    //FFFF after which a stop bit is issued

         I2caRegs.I2CSAR = 0x50;

         I2caRegs.I2CMDR.all = 0x66A0;

         while(I2caRegs.I2CSTR.bit.XRDY== 0){}; //Wait till registers can be accessed

        I2caRegs.I2CDXR = 0x00; //Send high byte of the eeprom write location

         while(I2caRegs.I2CSTR.bit.XRDY== 0){}; //Wait till registers can be accessed   

        I2caRegs.I2CDXR = 0x00; //Send low byte of the eeprom write location

        //NOTE : First two transmissions to an eeprom must always be the address you want to read/write to

          for(i = 0; i < 0xFFFF; i++)

          {

            while(I2caRegs.I2CSTR.bit.XRDY== 0){}; //Wait till registers can be accessed

            I2caRegs.I2CDXR = 0x55; //Write a bunch of 0x55's to the EEPROM starting at address location 0x0000 of the eeprom

          }

    I2caRegs.I2CMDR.bit.STP = 1; //Send stop bit now

  • Thanks Vishal,

    Just the kind of thing I was looking for to force some data!

    Still no transitions on the clock line!

    My setup is: SYSCLK 60 MHz, PSC = 6, CLKH = 10, CLKL = 5

    I would think that once the address is set, then the write to the command register will immediately cause the Start bit and the first byte (A0) to go out.  I am triggering on a GPIO that I set at the start of your code, and unfortunately, the only pulse I see is my trigger going high!

    I am going to try another board in the morning just in case, but since the other ports work, I don't think the board is the problem.

    Joe

     

  • This is the setup I use

    void vInitSystem()

    {

    //------------Setting up CLKs, PIE-------------------------------------------------

      InitSysCtrl();            //Start up the clocks, SysCtrl.c

      InitPieCtrl();            //Initialize the PIE

      InitPieVectTable();        //Copy PIE tables from the bootROM to the RA

      //------------Setting up the I2C-------------------------------------------------

      InitI2CGpio();            //Switch GPIO pins to be I2C pins

      I2caRegs.I2CPSC.all = 9; //PSC = (SYSCLKOUT/MODCLK)-1 ,@100MHz sysclk and 10MHz Modclk

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

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

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

    }

  • Ah, "The problem, once solved, is simple"!

    Checking my clocks in th einit routine and realized that while they do not require EALLOW-EDIS the "SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1;" which is with them does!

    Actually found this when I went back and verified my register settings and realized they were all 0s  Makes sense, clock was not enabled so nothing was running.

    My numbers are in line with yours, and I will build on your snippet to R/W the EEPROM

    Thanks,  Joe