8051 registers based delay calculation
- Tuesday, August 10, 2010, 13:24
- B.Sc Electrical Engineering Notes, Microcontroller Notes
- 3 comments
This method is “invented” by “Saad Zahid” of CECOS University, when he was a student of 3rd year Electrical Engineering and it was his first time with such type of Course. He was working on this method for one week and after confirming this method’s reliability with his Lecturer Engr. Mansoor Habib he submitted it and was published on September 17, 2009.Good Job Saad.
Following is a method to calculate the delay subroutines without using timers in the Microcontroller: (Click Here to Download Pdf version for more examples)
| Delay | Calculations | Code | Remarks |
| 50mS
Xtal freq =11.0592MHz |
50mS/1.085uS
= 46082.9 |
||
| 46082.9/255 = 180.7 | Its an Odd Value, so round off the result i.e. 180.7 to the nearest even number i.e 182 | ||
| 46082.9 / x =182 | Find value of x | ||
| 46082.9 / 253 = 182 | We’ll load 253 in the inner most loop | ||
| 182 / 2 = 91 | Always do this, so its result will be our outer loop | ||
| Delay:Mov R0, #91
Here1:Mov R1, #253 Here:DJNZ R1, here DJNZ R0, here1 RET |
|||
| 500mS
Xtal freq =11.0592MHz |
500mS/1.085uS = 460829.5 | ||
| 460829.5 / 255 = 1807.1 | Odd number does not account as its not less than 255, innermost loop = 255 | ||
| 1807.1 / 255 = 7.086 | Round off to nearest higher even i.e 8 | ||
| 1807.1 / x = 8 | |||
| 1807.1 / 226 = 8 | Inner loop = 226 | ||
| 8 / 2 = 4 | Outer loop = 4 | ||
| Delay:Mov R0,#4
Here2:Mov R1, #226 Here1:Mov R2, #255 Here:DJNZ R2, Here DJNZ R1, Here1 DJNZ R0,Here2 End |
|||
| 1Second
Xtal freq= 20MHz |
1 / 0.6uS =
1.6 x 10e6 |
||
| 1.6 x 10e6 / 255 =
6536 |
Innermost loop= 255 | ||
| 6536 / 255 =
25.6 |
Not Even so make it even i.e. 26 | ||
| 6536 / x = 26 | |||
| 6536 / 251 = 26 | Inner loop 251 | ||
| 26/2 = 13 | Outer loop = 13 | ||
| Delay:Mov R0, # 13
Here2: Mov R1, # 251 Here1: Mov R2, #255 Here: DJNZ R2, Here DJNZ R1, Here1 DJNZ R0, Here2 Ret |
|||
About the Author
3 Comments on “8051 registers based delay calculation”
Write a Comment
Gravatars are small images that can show your personality. You can get your gravatar for free today!
assalam o alaikum. sir G, this page of delay calculation cannot be download. how to download its pdf formate
Dear there is a link in the last line before the table start it says: (Click Here to Download Pdf version for more examples). Click on it or right click and select “Save link as” or “Save target as”
asalam-o-alaikum sir im faizan ahmad zeb from cu 512 A. Sir i got 2 questions for you first what you did in your final year project? and last but not the least sir if we make final year project through sir shazad (lab engineer) but we clear the concept about our project, will our project accept?