The delays shown by Bruce are mistakenly wrong. The original code shows delay_cycles(59) That is delay for 59 cycles. So, by using Bruce's code as a start, you can make the delay for 59 cycles. This will give you the correct timings. Another thing, the oscillator is 20MHz. So, the initial define has to be
The above has a subroutine to give you an exact delay of 59 cycles. You can call the function from PBP like thisCode:define OSC 20000000 cntr byte 1 delay_cycles59: ' 2 cycles to get here asm MOVLW 11 ' 1 cycle MOVWF _cntr ' 1 cycle loop: DECFSZ _cntr,F ' 1 cycles (3*17+1 = 52) GOTO loop ' 2 cycles nop ' 1 cycle return ' 2 cycles endasm
Code:gosub delay_cycles59




Bookmarks