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 Nada

Hi,

I am trying to use the F28035 to write to an I2C eeprom. This is my own hardware and I am using GPIO pins 33 and 32 for SCL and SDA. I compiled the I2C example code (Example_2803xI2C_eeprom) making sure to change the GPIOs to match my hardware. I downloaded the code to my hardware but when I run the code I am not seeing any I2C signals on the GPIO pins.

Would anyone have an idea as to why this is not working.

thanks,

Liam

 

  • Hi Liam,

    Can you please paste your implementation? Because from what you've described above it seems that I2C has not been initialized properly.

    Regards,

    Gautam

  • Hi Gautum,

    This is the function for intialising the GPIO as I2C

    void InitI2CGpio()
    {

       EALLOW;

    /* Enable internal pull-up for the selected pins */
    // Pull-ups can be enabled or disabled disabled by the user.
    // This will enable the pullups for the specified pins.
    // Comment out other unwanted lines.

    // GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0;    // Enable pull-up for GPIO28 (SDAA)
    // GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0;    // Enable pull-up for GPIO29 (SCLA)

     GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0;    // Enable pull-up for GPIO32 (SDAA)
     GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0;    // Enable pull-up for GPIO33 (SCLA)

    /* Set qualification for selected pins to asynch only */
    // This will select asynch (no qualification) for the selected pins.
    // Comment out other unwanted lines.

    //    GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3;  // Asynch input GPIO28 (SDAA)
    //   GpioCtrlRegs.GPAQSEL2.bit.GPIO29 = 3;  // Asynch input GPIO29 (SCLA)

     GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3;  // Asynch input GPIO32 (SDAA)
      GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3;  // Asynch input GPIO33 (SCLA)

    /* Configure I2C pins using GPIO regs*/
    // This specifies which of the possible GPIO pins will be I2C functional pins.
    // Comment out other unwanted lines.

    // GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 2;   // Configure GPIO28 for SDAA operation
    // GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 2;   // Configure GPIO29 for SCLA operation

     GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1;   // Configure GPIO32 for SDAA operation
     GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1;   // Configure GPIO33 for SCLA operation

        EDIS;
    }

    Function below is from Example_2803xI2C_eeprom.c

    void I2CA_Init(void)
    {
       // Initialize I2C


     I2caRegs.I2CMDR.all = 0x0000; // Put I2C in reset  added by me
       I2caRegs.I2CSAR = 0x0050;  // Slave address - EEPROM control code

       I2caRegs.I2CPSC.all = 6;      // Prescaler - need 7-12 Mhz on module clk
       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.I2CMDR.all = 0x0020; // Take I2C out of reset
              

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

       return;
    }

     

    Apart from changing the GPIOs to use GPIO33 and 32 and adding a few debug signals to  Example_2803xI2C_eeprom.c , my code is the same as the example code

    Liam

     

  • Hi,

    This initialization seems to be fine. What about other header files? You'll have to alter rest of the files too. Please go through all the hard header files included in the project that seem to be for I2C.

    Regards,

    Gautam