Continue to Site

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.

  • 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.

how to calculate the register value for a desired delay in 8051 Microcontroller

Status
Not open for further replies.

priyatosh

New Member
Dear Sir/Madam

Could any one help me, How to calculate the reg. value to achieve a desired delay in 8051 micro controller. Suppose I need 250ms delay .What should be the reg. value ,I have to take.

Thank you
Priyatosh Paul
 
Last edited by a moderator:
It depends on the crystal frequency and how your delay loop is written. Try Googling "8051 delay loop calculator".
 
DELAY: MOV R2,#200 1
AGAIN: MOV R3,#250 1
HERE: NOP 1
NOP 1
DJNZ R3,HERE 2
DJNZ R2,AGAIN 2
RET 2

For HERE loop, we have (4x250)x1.085μs=1085μs. For AGAIN loop repeats HERE loop 200 times, so we have 200x1085μs=217000μs. But “MOV R3,#250” and “DJNZ R2,AGAIN” at the start and end of the AGAIN loop add (3x200x1.805)=651μs. As a result we have 217000+651=217651μs.

just keep in mind Clocks per Machine Cycle

DS89C420/30/40/50 Dallas Semi 1
DS5000 Dallas Semi 4
P89C54X2 Philips 6
AT89C51 Atmel 12
 
from the The 8051 Microcontroller and Embedded Systems Using Assembly and C-2nd-ed
Very helpful for me

I should also add that was assuming one machine cycle lasts 12 oscillator periods like the AT89C51 and also using a 11.0592 MHz crystal
11.0592/12 = 921.6 kHz;
machine cycle is 1/921.6 kHz = 1.085μs
 
Last edited:
If a memory chip of size 256 kilobytes (256 x 1024 x 8 bits),
how many wires does the address bus need, in order to be able to specify an address in
this memory?

Thanking you
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top