Software Delays:: Delayreg. Next, We Need To Decide How Big A Number To Start Counting From
Software Delays:: Delayreg. Next, We Need To Decide How Big A Number To Start Counting From
Software Delays:: Delayreg. Next, We Need To Decide How Big A Number To Start Counting From
SoftwareDelays
SoftwareDelays:
Theprincipleofthesoftwaredelayisthatwecountdownfromapreviouslysetnumber,andwhenit
reacheszero,westopcounting.Thezerovalueindicatestheendofthedelay,andwecontinueonwith
theprogram.
So,thefirstthingweneedtodoistodefineaconstanttouseinthecounter.Wewillcallthisconstant
Delayreg.Next,weneedtodecidehowbiganumbertostartcountingfrom.
Example:
Q1.Developaflowchartandwriteanassemblylanguagesubroutine,forthePIC16F84microcontroller,
http://www.electronics.dit.ie/staff/tscarff/Delays/software_delays.htm
1/2
7/7/2015
SoftwareDelays
thatwillproduceadelayof150s.Assumethattheinternalclockcycletimeis1s.
ForthePIC16F84microcontrollerinstructionsetthenumberofcyclesare:
Cycles=150at1s
Delaymovlw.491
movwfdelayreg1
Loopdecfszdelayreg1/2
gotoLoop2
Return2
Totalnumberofcyclesis:
T=1+1+[(N1)x3)]+2+2=150cycles,whereN=numberofloops
SoforN=49thenT=150cycles
Soforaninternalclockcycletimeof1usthedelayis150s.
http://www.electronics.dit.ie/staff/tscarff/Delays/software_delays.htm
2/2