Electronic – I2C with PIC32 and MCP4706 Not Working

cdaci2cmicrochippic

We're working on a battery charger for an electric bicycle at the moment, but prototyping with a PIC32MX695F512H kit board and an MCP4706 DAC soldered onto a breakout board, programmed using a PICKIT3. We've got a few other peripherals all working so far, including a 20×4 LCD also over I2C, so at least that is working. Our issue is that our DAC operates on and outputs 5V, regardless of whether or not we have a Vref connected. (the chip defaults to short Vref to Vdd if nothing is connected to the pins)

The output from the DAC goes to a voltage follower that controls a power MOSFET, allowing a variable amount of current to flow to the battery based upon readings from a current sensor (in-line) and voltage sensor across the battery terminals.

Relevant code snippets are attached below:

#define DAC 0x60
.
.
.
// Configure I2C registers
void ConfigI2C()
{
    //1 USES RD10 AS SCL1 AND RD 9 AS SDA1
    /// I2CxCON I2CxSTAT I2CxADD I2CxMSK I2CxTRN I2CxRCV
    I2C1BRG=0x186;                  //390 for 80MHz to 100KHz
    I2C1CONbits.A10M=0;             //Use 7-bit addresses
    I2C1CONbits.DISSLW=1;           //disable slew control for standard
    I2C1CONbits.ACKDT=0;            //Use and ACK not NACK
    I2C1ADD=22;                     //Sets slave address for PIC32
    TRISD=0;                        //Sets Port D to output
    I2C1CONbits.ON=1;               //turn on I2C
}
.
.
.
// Start
void I2C_start(void)
{
    I2C1CONbits.SEN=1;          //send start
    while(I2C1CONbits.SEN){}  //waits till start bit detected
}

void I2C_stop(void)
{
    I2C1CONbits.PEN=1;          //send stop
    while(I2C1CONbits.PEN){}    //waits till stop bit detected
}
.
.
.
void SendI2C3(char addrs,char regis, char data)
{
    char ack;
    I2C_start();
    ack=I2C_write(addrs); //Address for LED is 0x50
    ack=I2C_write(regis); //0xFE for LED
    ack=I2C_write(data);  //0x20to0x7F standard
    I2C_stop();
}

We just get Vref out. We've tried all 8 address the board can have, and no dice.

Anybody have any advice on how to help us? we've been stuck on this problem for a couple of days. Thanks.

Best Answer

We got it working about a week or two ago-- sorry for the delay. Turns out the chip was either fried or bad. We used another breakout board (it's a tiny package that was a pain to solder, and only had one breakout), soldered the chip on, works completely fine. Marking it solved.