I'm reading 1_wire header file for PIC18 with C18 compiler. in the write_byte function, they specified that in order to write bit1; we make line input and that will take it high. can we specify high or low output value in the TRIS port which specify i/o direction?
#define OW_LAT LATCbits.LATC1
#define OW_PIN PORTCbits.RC1
#define OW_TRIS TRISCbits.TRISC1
void ow_write_byte(unsigned char data)
{
char i;
for (i=0;i<8;i++)
{
// DQ Low
OW_LAT=0;
OW_TRIS=OUTPUT;
// Keep it low for 10us to start the WRITE
Delay10TCYx(10);
// Keep low i.e. keep output mode and low if WRITE0 (bit 0)
// or release line i.e. make input to take it high if WRITE1 (bit1)
OW_TRIS = data & 0x01;
Delay10TCYx(50);
// Release the line. Total of 60us
OW_TRIS=INPUT;
// Some recovery time between the bits 2us
Delay10TCYx(2);
data =data >>1;
}
}