Can someone advise me whether is my source code is correct? I am doing a = security warning system for my project and writing the program in PIC C. = The PIR sensor will sense for movement and the PIC18F452 Microcontroller = will get the data from the EEPROM and send it to the DAC using the I2C = bus. Both devices are I2C devices. Here is my source code. I am using = the MPLAB C18 complier to write the code. Please advise me. Component I'm using: Microcontroller : PIC18F452 EEPROM : Microchip 24LC256 DAC : MAX517 #include #include //function prototype void MAX517(unsigned int channel); void main(void){ char err, data_to_DAC, I2C_err; unsigned char *rdptr; int i; //init condition TRISB =3D 0X10; //Set PORTB Bit 4 as Input, the rest as output TRISC =3D 0X1A; //Set SDA & SCL as 1. Activate I2C port =20 OpenI2C(MASTER, SLEW_ON); //Initialize I2C module SSPADD =3D 9; //400KHz Baud clock (9) @16MHz =20 while(1){ //Start condition if(PORTBbits.RB4 =3D=3D 1){ //detect movement err =3D EESequentialRead(0xA1, 0x00, rdptr, 1); //make = current address at 0xA1 =20 for(i=3D0; i<4096; i++){ //8Kbyte per wave x 1024 x 4 = waves data_to_DAC =3D EECurrentAddRead(0xA1); //Read a = single byte EEPROM and store in temp I2C_err =3D EEAckPolling(0xA10); //Send Ack to PIC MAX517(data_to_DAC); //Write data to I2C DAC }//end for=20 }//end if }//end while }//end main void MAX517(unsigned int channel){ StartI2C(); //Start condition WriteI2C(0x58); //Address byte of DAC AckI2C(); //Ack WriteI2C(0x00); //Command byte AckI2C(); //Ack WriteI2C(channel); //Output Data AckI2C(); //Ack StopI2C(); //Stop condition }//end of MAX517 funtion -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu