Tool/software: Code Composer Studio
Hello,
Hoping someone can help me with this. I am trying to communicate with an I2C temperature sensor from Microchip (P/N: MCP9808) and it's not going so well.
If I disconnect the part from the board (I'm using a LaunchPad for this), I get the correct signals in the I2C bus. However, when I plug the sensor in, both lines stay high. After analyzing the signal with a scope, the SDA line goes down to only 2.2V instead of 0). It almost looks like the IO pins don't have low enogh impedance to drive the bus. Here is a snipped of the code showing how the IO's are setup.
void I2Cclass::Init(void)
{
//
// Initialize I2C
//
EALLOW;
/* Enable internal pull-up for the selected pins */
GpioCtrlRegs.GPBPUD.bit.GPIO32 = 1; // Disable pull-up for GPIO32 (SDAA)
GpioCtrlRegs.GPBPUD.bit.GPIO33 = 1; // Disable pull-up for GPIO33 (SCLA)
/* Set qualification for selected pins to asynch only */
GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3; // Asynch input GPIO32 (SDAA)
GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3; // Asynch input GPIO33 (SCLA)
/* Configure I2C pins using GPIO regs*/
GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1; // Configure GPIO32 for SDAA operation
GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1; // Configure GPIO33 for SCLA operation
EDIS;
//Configuring the I2C module
I2caRegs.I2CPSC.all = 20; // 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 = 0x00; //Interrupts not used.
I2caRegs.I2CMDR.all = 0x0020; //Take I2C module out of reset
I2caRegs.I2CFFTX.all = 0x6000; // Enable FIFO mode and TXFIFO
I2caRegs.I2CFFRX.all = 0x2040; // Enable RXFIFO, clear RXFFINT,
}