This code is part of the 1 wire protocol library found on the microchip website:
If a 1 is passed to this function. It is supposed to delay 1us. I thought each instruction took 4 clock cycles? So each instruction for a 12MHZ clock would be .3333us. But I am counting 5 instructions.
But loops actually take 8 clock cycles correct? Then I would see where the loop code would take 1 us with a 12mhz clock
So this function would not be accurate for smaller delays like one or two us but increase in accuracy and the delay is increased?
Is my assessment correct?
Rich (BB code):
#elif (CLK_FREQ_12000000)
#define wait(a) _asm movlw a\
movwf macro_delay,1\
loop: decfsz macro_delay,1,1\
bra loop\
_endasm
#define BAUD_RATE 18
#endif
But loops actually take 8 clock cycles correct? Then I would see where the loop code would take 1 us with a 12mhz clock
So this function would not be accurate for smaller delays like one or two us but increase in accuracy and the delay is increased?
Is my assessment correct?
Last edited: