Hi Ken, I tried it out today in my lab using the source code you provided, though there is still no output but i can step though the program from from the program memory using the MPLAB. I wonder is it my hardware connection is wrong. This is my connection: Pin 1 - output of DAC Pin 2, 5, 6 - Ground Pin 3 - SCL (2k pullup resistor) Pin 4 - SDA (2k pullup resistor) Pin 7 - 5V Pin 8 - No connection I still couldn't get any voltage at the Pin 1. What could be the problem? This is the source code after I implement. I will try again tomorrow. #include #include //function prototype void MAX517(unsigned char data_DAC, unsigned char I2C_Address); void main(void){ char data_DAC; char I2C_Address; //init condition TRISC = 0X1A; //Set SDA & SCL as 1. Activate I2C port OpenI2C(MASTER, SLEW_ON); //Initialize I2C module SSPADD = 9; //400KHz Baud clock (9) @16MHz while(1){ //Start condition data_DAC = 0xFF; MAX517(data_DAC, I2C_Address); //Write data to I2C DAC }//end of while }//end of main void MAX517( unsigned char data_DAC, unsigned char I2C_Address ) { I2C_Address &= 0x58; // Coerce 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 } ----- Original Message ----- From: "Ken Pergola" To: Sent: Thursday, March 18, 2004 4:03 AM Subject: Re: [PIC]:I2C DAC test > Hi Nicholas, > > Now wonder you are having problems -- see what happens when you provide > extra details? > > When I first looked at your code, I thought it was written by you. I thought > your reference to the function 'AckI2C()' was a check for slave acknowledge, > but now that I know you are using the C18 compiler, the 'AckI2C()' is a > function that generates a MASTER ACK which is what you do not want. It looks > like the WriteI2C() function automatically checks for a slave ACK. > > > Therefore, try this (remove all 'AckI2C()' from your DAC code): > I changed the int you were using to unsigned char, and made some other > changes. > > > > void MAX517( unsigned char DataByte, > unsigned char I2C_Address ) > { > I2C_Address &= 0xFE; // Coerce address byte to WRITE mode > > StartI2C(); // Start condition > > WriteI2C(I2C_Address); // Address byte of DAC > > WriteI2C(0x00); // Command byte > > WriteI2C(DataByte); // Output Data > > StopI2C(); // Stop condition > } > > > Let us know if this works. You might also want to process the function > return code of the WriteI2C() function, but for now just try to get the DAC > working. > > Also, I would recommend a stiffer voltage reference versus the resistive > voltage divider Vref that you are currently using. > If you need help selecting a voltage reference just come on back with some > questions. If you are breadboarding, you can easily find them in a TO-93 > package. > > Best regards, > > Ken Pergola > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > -- 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