Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

I2C Nothing

$
0
0

Well I have been trying to get my TMS320F28069U I2C module working for a few days now and all I can do is generate a start condition on the bus...I have implemented and used plenty of other I2C modules but I am very displeased with the lack of documentation in this feature.

For example there is no explanation about FIFO mode and its usage verse non-FIFO mode. There is a register description and that is it...

So here is my code...it is nearly exactly (functionally it is exact, except it doesn't work) as what the example is in the ControlSuite so please tell me what I am doing wrong.

// Setup for I2C pins and peripheral clock.

    // GPIO32 - uC_CSAC_SDA
    GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0;        // Enable pull-up for GPIO32 (SDAA)
    GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3;      // Asynch input GPIO32 (SDAA)
    GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1;    // 0=GPIO,  1=I2CSDA,  2=SYNCI,  3=ADCSOCA

    // GPIO33 - uC_CSAC_SCL
    GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0;        // Enable pull-up for GPIO32 (SCLA)
    GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3;      // Asynch input GPIO32 (SLCA)
    GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1;    // 0=GPIO,  1=I2CSCL,  2=SYNCO,  3=ADCSOCB

    SysCtrlRegs.PCLKCR0.bit.I2CAENCLK = 1;         // I2C-A

// I2C initialization

    void I2C_Init(void)
    {
        // Just like the example...
        I2C_DISABLE;                                              // Disable I2C module for IPSC initialization (IRS = 0).
        I2caRegs.I2COAR = 0x0007;                    // I2C_ master address.
        I2caRegs.I2CPSC.all = 7;                          // Set I2C module clock (not SCL) to 10MHz for specified operation, systemclock = 80MHz.
        I2caRegs.I2CCLKH = 45;                          // Set I2C SCL to 100kHz operation (high time multipler).
        I2caRegs.I2CCLKL = 45;                           // Set I2C SCL to 100kHz operation (low time multipler).
        I2caRegs.I2CIER.all = I2C_INTS;             // No interrupts set.
        I2C_ENABLE;                                                // Enable I2C module for initialization (IRS = 1).
        I2caRegs.I2CFFTX.all = 0x6000;               // Enable FIFO mode and TXFIFO.
        I2caRegs.I2CFFTX.bit.TXFFINTCLR = 1; // Does not clear the INT although it says it will.
    }

// I2C Write (only generates start condition)

    char I2C_Write(char *local_buffer_ptr, char local_buffer_cnt)
    {
        unsigned char i;

        if(I2caRegs.I2CMDR.bit.STP == 1)
        {
            return I2C_STP_NOT_READY_ERROR;
        }
        I2caRegs.I2CSAR = 0x0024;            // Load I2C slave address.

        if(I2caRegs.I2CSTR.bit.BB == 1)
        {
            return I2C_BUS_BUSY_ERROR;
        }
        I2caRegs.I2CCNT = local_buffer_cnt;    // Load number of bytes to be transmitted.

        for(i = local_buffer_cnt; i > 0; i--)
        {
            I2caRegs.I2CDXR = *local_buffer_ptr;
            local_buffer_ptr++;
            local_buffer_cnt--;
        }
        I2caRegs.I2CMDR.all = 0x6E20; // Master, transmitter, start and stop.
        I2C_Tran_Flag = 0;
        return 0;
    }

So I see all the initializations and such go into the appropriate registers, I see the slave address and the count set but all I get out is a start condition. Please advise!


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>