I'm trying to communicate with the LDC1612 through an I2C interface, using my C2000 F28069M board. I've configured pins 9 and 10 (GPIO 33 and 32 respectively) to be the I2C SCL and SDA lines.
This is my GPIO configuration:
EALLOW; GpioCtrlRegs.GPAMUX1.all = 0x00000000; // GPIO0 - GPIO15 GpioCtrlRegs.GPAMUX2.all = 0x05000000; // GPIO16 - GPIO31 GpioCtrlRegs.GPBMUX1.all = 0x00000005; // GPIO32 - GPIO44 GpioCtrlRegs.GPBMUX2.all = 0x00000000; // GPIO50 - GPIO58 GpioCtrlRegs.GPADIR.all = 0x20030000; // Direction of GPIO0 - GPIO31 GpioCtrlRegs.GPBDIR.all = 0x00000087; // Direction of GPIO32 - GPIO44 GpioCtrlRegs.GPAQSEL1.all = 0x00000000; // GPIO0 - GPIO15 GpioCtrlRegs.GPAQSEL2.all = 0x03000000; // GPIO16 - GPIO31 GpioCtrlRegs.GPBQSEL1.all = 0x00000003; // GPIO32 - GPIO44 GpioCtrlRegs.GPBQSEL2.all = 0x00000000; // GPIO45 - GPIO58 GpioCtrlRegs.GPAPUD.all = 0x00000000; // GPIO0 - GPIO31 GpioCtrlRegs.GPBPUD.all = 0x00000084; // GPIO32 - GPIO58 EDIS;
Other than that, I've defined the address of the LDC1612 here.
#define INDUCT_SLAVE_ADDR 0x2A
I've grounded both the ADDR and the GND pins on the LDC 1612, and I have Pin 9 (SCL) going to SCL on the sensor, with Pin 10 (SDA) also going directly into the sensor's SDA pin. And finally I have one of the 3.3V pins on the board going into the sensor (I've checked there is power going to the Inductance Sensor).
Now, my problem is that whenever I try to read or write to the LDC1612, I am unable to receive so much as an acknowledgement-bit, leaving my code infinitely looping while it waits for IcaRegs.I2CSTR.bit.XRDY to change to 1. This is the code I'm using to try and read the Data channel:
unsigned int i = 0; unsigned long registerData = 0; // We need a long because the data is 28-bits, ints are 16 while (I2caRegs.I2CSTR.bit.BB == 1) {}; // Wait for the I2C bus to free up I2caRegs.I2CSAR = INDUCT_SLAVE_ADDR; I2caRegs.I2CCNT = 1; I2caRegs.I2CDXR = (channel == 0) ? 0x00 : 0x02; I2caRegs.I2CMDR.bit.TRX = 1; // Set the module to transmission mode I2caRegs.I2CMDR.bit.MST = 1; // Set the module to Master mode I2caRegs.I2CMDR.bit.FREE = 1; // Run in free mode (doesn't stop at debugger breakpoints) I2caRegs.I2CMDR.bit.STP = 0; // Don't release the bus after transmission I2caRegs.I2CMDR.bit.STT = 1; // Send a start bit while (I2caRegs.I2CSTR.bit.XRDY == 0) {}; // Do nothing until the previous command is processed I2caRegs.I2CCNT = 4; // Set read-count to four data bytes I2caRegs.I2CMDR.bit.TRX = 0; // Set the module to receive mode I2caRegs.I2CMDR.bit.MST = 1; I2caRegs.I2CMDR.bit.FREE = 1; I2caRegs.I2CMDR.bit.STP = 1; // Tell the module to STOP when the I2CCNT value has been reached I2caRegs.I2CMDR.bit.STT = 1; // Repeated start, Reception will follow // The data registers are 4 sequences of 8-bits. The first 4 bits are error codes, i.e. not useful for (i = 0; i < 4; i++) { // Read the register (who's value is 2 bytes, so two I2C data sequences) while (I2caRegs.I2CSTR.bit.RRDY == 0){}; // Wait for the bus to be free I2CRxData[i] = I2caRegs.I2CDRR; // Actually read the data } registerData = ((long)I2CRxData[0] & 0x07); registerData = registerData << 8; registerData = registerData + (long)I2CRxData[1]; registerData = registerData << 8; registerData = registerData + (long)I2CRxData[2]; registerData = registerData << 8; registerData = registerData + (long)I2CRxData[3];
Looking at the SDA channel on an oscilloscope, I see the Start bit -> 7 Address bits equaling 2A -> a LOW signal corresponding to a Write command -> high signal on the SDA line for the rest of the program.
This is my first program using I2C at this level, so I'm probably missing something very simple. Thanks in advanced!