1
\$\begingroup\$

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 20x4 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.

\$\endgroup\$
5
  • \$\begingroup\$ Do you see anything happening on the lines when viewing at the oscilloscope or logic analyzer? \$\endgroup\$ Commented Mar 21, 2013 at 0:53
  • \$\begingroup\$ Didn't even think of that. We're hooking it up right now to take a look. \$\endgroup\$
    – alextoombs
    Commented Mar 21, 2013 at 0:58
  • \$\begingroup\$ This is only a 6 pin device. Desolder it and try another one. You could waste a lot of time on a problem that is specific to just one instance of a bad device. Which package do are you using for that DAC, by the way? SOT or DFN? \$\endgroup\$
    – Kaz
    Commented Mar 21, 2013 at 1:09
  • \$\begingroup\$ Is the working 20x4 LCD on the same I2C bus? That tends to confirm that the bus traces are working. \$\endgroup\$
    – Kaz
    Commented Mar 21, 2013 at 1:15
  • \$\begingroup\$ Same I2C bus, LCD still working. SOT package, so while it's a pain to solder, I can always try another device. \$\endgroup\$
    – alextoombs
    Commented Mar 21, 2013 at 1:22

2 Answers 2

2
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

You're configuring the I2C lines as outputs.

TRISD=0;                        //Sets Port D to output

The output drivers may be interfering. Try configuring them as inputs. (This is what I have to do on PIC24.)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.