![]() |
|
|||||||
| Programmer's Corner Discussion forum for all aspects of programming and software engineering. Any software programming language welcome: C, C++, C#, Fortran, Java, Matlab, etc. |
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hello,
I am programming 8051 microcotroller in assembly and I'm trying to stop the program for 10 seconds and then continue with the rest of the program. Any ideas on how to do this? -MLCC |
|
#2
|
||||
|
||||
|
One classic way to make a delay is to use nested decrement loops. Every time the inner loop counts down to 0, then the next decrements, and so on.
It's a bit tedious to adjust the timing, and interrupts will mess with the process, but it works.
__________________
First comes the hardware, then the software. |
|
#3
|
|||
|
|||
|
MLCC,
Quote:
Ratch |
|
#4
|
|||
|
|||
|
The Loop is what seems to do the trick, although, is their a more efficient way to do this? (I need a example with it too, I'm very new to programming microcontrollers)
|
|
#5
|
||||
|
||||
|
Quote:
1. A loop making use of counters, as mentioned by beenthere. - To get the exact timing, you have to know your instruction speed with respect to the clock that you are using.2. A loop that waits for a pre-set timer interrupt. Normally most microcontrollers have this feature. |
|
#6
|
|||
|
|||
|
MAIN:
MOV TMOD,#10H ; Init timer 1 ....... ....... SETB TR1 ; Start timer 1 LCALL DELAY ; DELAY: MOV R1,#200D ; 200 x 50 ms = 10 sec D1: MOV TH1,#3CH MOV TL1,#B0H D2: JNB TF1,D2 ; timer overflow in 50 ms CLR TF1 DJNZ R1,D1 ; loop 200 times RET |
|
#7
|
|||
|
|||
|
here is a link explaining different types of delay subrouines:
http://www.dnatechindia.com/index.ph...ontroller.html here is a link for few working codes that u may find useful http://www.dnatechindia.com/index.php/Code-Library/ |
|
#8
|
|||
|
|||
|
Assembly and C/C++ are just the most awesome, greatest languages EVER in programming history...
I'm not sure if 8051 chip has these type of instructions, but what about a couple of NOP ; No Operation instruction I supose this might not be enough delay/wait for you anyhow?
__________________
Developer_Dan() Programmer and Software Developer |
|
#9
|
|||
|
|||
|
It would take more than a couple of NOP instructions to wait 10 seconds, and the number needed would depend on the clock speed of the 8051 microcontroller, and how long it takes to process a NOP.
__________________
"The floggings will continue until morale improves!" |
|
| Tags |
| assembly, delay, program |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 55 Sec Time Delay in Assembly Language | pauliewalnuts | Embedded Systems and Microcontrollers | 8 | 06-17-2008 06:20 AM |
| Assembly Program (digit conversion) | frogacult | Programmer's Corner | 4 | 05-11-2008 05:15 PM |
| Assembly Program | frogacult | Programmer's Corner | 5 | 05-08-2008 03:41 PM |
| Assembly Program For Transmitting And Receiving A Message Using Ms-dos Debug | Diana | Programmer's Corner | 5 | 06-22-2007 04:09 AM |
| Assembly Language program | Thinker | Programmer's Corner | 18 | 05-23-2007 03:01 PM |
| Thread Tools | |
| Display Modes | |
|
|