Environment: MPLAB X IDE + HI TECH Compiler for PIC16
#define OW_TRIS TRISA0 //Port mode register, 1=input,0=output #define OW_PORT RA0 //Pin connected to 1-wire bus int owReset(void) { char state = 0; OW_TRIS = 0; //Set as output OW_PORT = 0; //Drive Low __delay_us(480); OW_TRIS = 1; //Release, Set back as input __delay_us(70); state = !OW_PORT; //If devices are present, it will keep the pin low //! will invert 1=0, 0=1 __delay_us(410); return state; //Returns 1 if devices are present }