Discussion in "8051 Discussion Forum" started by    Khadka_Bishal    Mar 16, 2018.
Fri Mar 16 2018, 11:34 AM
#1
I want to have a delay of 15 microsecond in 8051 using a crystal oscillator of 11.0592 MHz. .

To test the delay, i toggle port pin 1.0 for every execution of delay.
The code and its calculations are shown in code's comment section below

====================================================================
ORG 00h
MOV TMOD,#01 ;TIMER0 -> MODE1
;No. of machine cycle = 480uS/1.0850693us = 14
; 2^16 - 14 = 65522
; ( 65522 ) dec = ( FFF2 )hex
; The required value to generate 15us is (FFF2)16
; BUT, there is extra delay of 17 us due to execution of
;other codes except the delay loop
; To Compensate this,
; i add (17)dec =(11)hex to FFF2 = 1 0003 which exceed
; the max value FFFF.
; but i loaded the maximum value i.e. FFFF to timer reg
; and still i got a delay of 17 uS

LOOP:
CPL P1.0
ACALL DELAY15
SJMP LOOP


DELAY15:
MOV TH0,#0FFH
MOV TL0,#0FFH
SETB TR0
HERE: JNB TF0,HERE
CLR TR0
CLR TF0
RET
END
===================================================================

Even assigning the timer register its maximum value i am not getting delay of 15 uS (microsecond) . I have checked for the code optimization as well but i didn't see ta single step that could be either eliminated or optimized.

Please help on it !
Sat Mar 17 2018, 09:26 PM
#2
CPL P1.0 3
ACALL DELAY15 6
SJMP LOOP 3

DELAY15:
MOV TH0,#0FFH 2
MOV TL0,#0FFH 2
SETB TR0 3
HERE: JNB TF0,HERE 4
CLR TR0 3
CLR TF0 3
RET 4

total 33 = 17.9 uS

Instructions need different numbers of machine cycles.
I have noted the number needed for each instruction in your loop.
I get a total of 33.
You must be using a version of the 8051 that has
6 clock cycles per machine cycle.
Older types use 12 clock cycles per machine cycle.
33 machine cycles take around 17 uS as you found.

One obvious way to speed up the loop is to
not use a subroutine.
Put the delay "inline".
This saves the ACALL and RET.
You don't need Timer0 at all, you could just
just use a software loop.

LOOP:
CPL P1.0 3
// DELAY15:
MOV TH0,#0FFH 2
MOV TL0,#0FFH 2
SETB TR0 3
HERE: JNB TF0,HERE 4
CLR TR0 3
CLR TF0 3
SJMP LOOP 3

total 23 = 12.4 uS

Get Social

Information

Powered by e107 Forum System

Conversation

Mon Oct 22 2018, 09:34 AM
JIMI吴
首席阿里巴巴zzzzzzzzzz
Mon Oct 22 2018, 08:58 AM
Sylvia
For a limited time we have lowered the rate on targeted website traffic. We have visitors from virtually every country on Earth. Each visitor is targeted by both country and keywords that you submit when you start your free trial period. If you need more visitors or product sales try our service free for seven days and we will send you 500 free visitors during the trial. There are no contracts and if you cancel during the trial period you will not be charged anything! Start your trial today: http://s.miku.moe/jbpuz
Mon Oct 22 2018, 05:37 AM
Iris Spain
aaa快乐是大家的aaa
ExperimenterUK
Sat Sep 29 2018, 06:28 PM
Please post questions in the forum.
Sat Sep 29 2018, 11:26 AM
Ashfaq Ch
hi i have some AT89C51RC microcontrollers already programed. some one help us to how to download from AT89C51RC and after study and edit all corractions reload to AT89C51RC controller
shshistiem
Wed Sep 12 2018, 10:58 PM
hii!! some1 please let me know how i ll get rfid code to 8051 by WEIGAND mode
DrNossberg
Tue Sep 11 2018, 08:09 PM
is there anyone here?
Mon Aug 27 2018, 07:30 AM
bun
Hello everyone!
Sat Jul 21 2018, 06:21 AM
Dibakar Bhanja Chowdhury
By using a 555 timer how can I expand the range of the mobile phone jammer? Please reply me asap
Sun May 20 2018, 10:01 AM
justinb
how to write and execute a program that read the keypad button and display the number on 7 segment on intel8051 at89s52 in assembly language?

Downloads

Comments

PCBindex
Fri Sep 14 2018, 02:45 AM
sirkit
Thu Sep 13 2018, 04:46 AM
shshistiem
Wed Sep 12 2018, 10:36 PM
DrNossberg
Tue Sep 11 2018, 03:25 PM
ranjanvh
Thu Sep 06 2018, 02:28 PM
rbbhamre
Tue Sep 04 2018, 06:15 PM
Tressie
Sun Sep 02 2018, 02:20 PM
Sudhansudeep
Fri Aug 31 2018, 08:26 AM

Online

Guests: 53, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38006
Newest member: PCBindex
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Sep 13 2018, 08:39 PM
First of all, by reading your reply, I abandoned m...
DrNossberg Avatar
Posted By DrNossberg
Thu Sep 13 2018, 03:49 PM
Hi, thanks you for your reply ^^ First of all, by ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Wed Sep 12 2018, 12:12 AM
HiThere are several issues here.The original 8051 ...
DrNossberg Avatar
Posted By DrNossberg
Tue Sep 11 2018, 08:08 PM
Hello everybody!First of all let me explain some s...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Sep 07 2018, 05:08 AM
The compiler thinks the micro doesn't have enough...
Sudhansudeep Avatar
Posted By Sudhansudeep
Fri Sep 07 2018, 02:59 AM
this is the build output message
Sudhansudeep Avatar
Posted By Sudhansudeep
Fri Sep 07 2018, 01:38 AM
Change the mobile number as [number removed] in t...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Sep 06 2018, 08:56 PM
I don't know what the problem is, I get no errors....
Sudhansudeep Avatar
Posted By Sudhansudeep
Thu Sep 06 2018, 01:12 PM
the code is Attachment ...
Sudhansudeep Avatar
Posted By Sudhansudeep
Thu Sep 06 2018, 12:48 PM
the code is same as u sent me for 16 chars