How to generate delay using register banks?

Status
Not open for further replies.

mohansaini

Junior Member level 1
Joined
May 22, 2010
Messages
18
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
india
Activity points
1,414
delay generation

hi guys i m a new member and it,s my new post ever in any discussion forum...
i m using µc P89V51RD2FN i just want to start with how to generate a delay using register banks ..
plz explain the concept from a zero level...
as how to calculate machine cycle, use of crystal frequency which is 11.0592mhz...
hex values to be stored in registers,
 

Re: delay generation

hi, refer 8051 micro controller by mazidi book for examples of delay generation.


here is my sample code
Code:
DELAY:;REG USED R4,5,6,7    crystal:11.0592mhz
;CPL P3.6
;1S DELAY STARTS HERE{1000*1MS}
MOV R4,#04H;1C
DL3:
MOV R5,#249D;1C

;1MS DELAY STARTS HERE{922*1.085*E-6}=1.00037*E-3
DL2: MOV R7,#02H;1C ---    DELAY
   D1: MOV R6,#225D;  1C   FOR
  DL1: DJNZ R6,DL1; 450C 1 MS
     DJNZ R7,D1; 2C+ [450*2]+4C=906C
     MOV R7,#07;  1C
     DJNZ R7,$;   14C
     ;NOP
     ;NOP
     ;NOP;----------1C.TOTAL(922*1.085*E-6=1.00037*E-3[APPROX 1MS])
    
;1MS DELAY END HERE
     
DJNZ R5,DL2
DJNZ R4,DL3; FROM START TO HERE TOTAL 920317 CYCLES
MOV R7,#03H; 1C----------|
DL6:MOV R6,#219D;        |
DL5:DJNZ R6,DL5;
DJNZ R7,DL6;--->  [1C+(1C+220*2)*3+6C=1324C]. 920317+1324=921641C
MOV R7,#07;1C
DJNZ R7,$;   14C      Y
NOP;         1C     CLES     
NOP;         1C
;NOP; INCLUDING CALL AND RET
RET;TOTAL (920317+1324+18C=921659)*1.085E-6=1S
;welove8051.com
;free8051projects.blogspot.com


regards
kj
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…