Hey Ken, So sorry, by the way, what is this pointer used for? I dun quite understand? Can advise me? I2C_Address &= 0x58; Is this the right way of writing it? void MAX517( unsigned char data_DAC, unsigned char I2C_Address ) { I2C_Address &= 0x58; // Source address byte to WRITE mode StartI2C(); // Start condition WriteI2C(I2C_Address); // Address byte of DAC WriteI2C(0x00); // Command byte WriteI2C(data_DAC); // Output Data StopI2C(); // Stop condition } Nicholas ----- Original Message ----- From: "Ken Pergola" To: Sent: Friday, March 19, 2004 12:21 AM Subject: Re: [PIC]:I2C DAC test > Hi Nicholas, > > Nicholas you definitely want to initialize 'I2C_Address' otherwise your code > will not work: > > Try this: > > char I2C_Address = 0x58; > > Instead of: > char I2C_Address; > > > > The actual 7-bit slave device address for the way you wired the MAX517 (with > pins AD1, AD0 grounded) is 0x2C. > But when the slave address is coerced into the 8-bit 'I2C_Address' because > of the R/W bit, it becomes 0x58. > So you did your homework well and came up with 0x58. :) > > Nicholas, I think your best course of action is to test the function return > code of the 'WriteI2C()' function like I mentioned in my last post. This > will provide you with some useful information. You should really test and > act upon the function return code in future code, but for now, just test the > return value to see what you get. > > I've always written my own I2C routines in HI-TECH PICC, PICC-18, and > PICC-Lite. I have never used the Microchip C18 compiler. > You main goal is to see if your slave ACKs your control byte correctly -- I > would imagine that this status is reflected in 'WriteI2C()' funtion code > status. > > Nicholas, in your pinout you said 'Pin 8 - No connection' -- this is where > you want to feed your voltage reference. > Isn't this the pin you said yesterday you connected to a voltage divider? > I'm confused now. You definitely do not want that pin as a NO CONNECT since > that's you voltage reference input. You could tie that pin to Vdd for now. > Then if you sent 0x7F to the DAC (output byte) you would expect > approximately Vdd/2 on your DAC output pin. > > I'm about a day away from a Master I2C/SMBus Engine (MISE) release that > could validate your project I2C hardware in a few minutes. > The MISE utility give you interactive feedback on your I2C transactions so > that you'll know if the START condition worked, if the control byte was > ACKed by the slave, etc. > > > I'm assuming that the MAX517 does not have a half-buffered output (some DACs > like the TLC5620 do) -- just check the data sheet to make sure. > > > Make that change I mentioned above and please report back. > > Good luck. > > Ken Pergola > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics