Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
i used interrupt add my adc program and some doubt the calculation.
my operating frequancy 20mhz. i want20us delay .how to calculate this?
please help me? iam waiting your valid replay
I guess that you are using a 16F series PIC. For those, the PIC takes 4 clock cycles to execute one instruction.
A 20 MHz clock has a cycle time of 50 ns so 4 cycles is 200 nS. A 20 µs delay is 100 instruction cycles.
A delay loop of 100 cycles would look something like this:-
Code:
movlw d'33'
movwf delay_reg ; You need to define a register for this
delay_loop
decfsz delay_reg, f
goto delay_loop
That just goes round the loop 33 times. The GOTO instruction takes 2 instruction times, so the loop takes 3 instruction times. Running it 33 times takes 100 cycles (might not be exact, but it is close) so just about 20 µs at 20 MHz
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.