Can you place it in a cycle for the time you need.
Maybe get it to shift right a few hundred times for no particular reason but to waste time.
Am I talking rubbish ?
2006-08-19 02:23:15
·
answer #1
·
answered by Henry 5
·
0⤊
1⤋
One method requires you first make a count-down timer that runs off a h/w timer interrupt. I am assuming 10ms resolution is good enough.
cdown rmb 2 # Place for count down
tick10 rmb 1 # Required if timer cannot do exact 10ms
interrupt handler (pseudocode)
clear the interrupt
re-enable timer interrupt
if ticksm !=0
dec tick10
bne getout
# 1ms has expired
reload tick10
if cdown != 0
decrement it (16 bit)
getout:
rti
Then in your main code when you want a specific delay..
load #time to delay such as 130 for 1.3 seconds (130 10ms intervals)
disable interrupt (timer or all)
store in cdown
enable interrupt
Now your code can sit around wating for cdown to reach zero, or go do other stuff and check cdown from time to time
You will have to figure out how to program a timer to generate an a regular interrupt and put the address of the interrupt handler in the the timer's interrupt vector location.
Also, you need to program it for some integer fraction of the 10ms period (if it won't do 10ms in one shot) and set that as the standard count-down in tick10. Remember to initialize tick10 before using the cdown as a timer (a defined constant is good).
There are other ways to do this, some more efficient, but this is conceptually easier to deal with.
I would give you more processor specific detail, but I've worked mostly with 68hc11/12/9s12 stuff and not the '08 series.
2006-08-19 04:33:16
·
answer #2
·
answered by sheeple_rancher 5
·
0⤊
0⤋
Set up a timer interrupt for, say 100 milliseconds. In the interrupt increment a counter and when it hits 4 (.4 seconds) set a flag to do whatever it is you need to do (or just do it in the interrupt). When it hits 6 (.6 seconds) do the same, and so on when it hits 13 (1.3 seconds). When it hits 13, reset it to 0 to cycle through again if thats what you want. Or you could make 3 counters, one for each delay, it just depends on how you are going to use them.
2006-08-19 02:52:26
·
answer #3
·
answered by justme 7
·
0⤊
0⤋
Depends on what you have access to on your machine. Either write delay loops that do nothing but spin in loops for large numbers of clock cycles, or if you have timers and interrupts, set those up. I'm assuming this is for school and on a very simple board since you're working in machine language and have LEDs for output. If you were running a real-time OS, there would be other methods.
2006-08-19 04:31:11
·
answer #4
·
answered by Ken H 4
·
0⤊
0⤋
Do you've already got you ever 8051 uC equipped right into a circuit with all of those sensors? Why did you %. the 8051? do you ought to construct this circuit or are you able to employ off the shelf elements to bolt at the same time the function. if so you should use a %or yet another more convenient microcontroller like a uncomplicated stamp. the mandatory stamp is designed as an academic get admission to indicate for microcontrollers
2016-11-26 01:34:47
·
answer #5
·
answered by Anonymous
·
0⤊
0⤋
you can use:
Delay PROC
;
; Create an n-millisecond delay.
; Receives: EAX = milliseconds
; Returns: nothing
; Remarks: May only used under Windows 95, 98, or ME. Does
; not work under Windows NT, 2000, or XP, because it
; directly accesses hardware ports.
; Source: "The 80x86 IBM PC & Compatible Computers" by
; Mazidi and Mazidi, page 343. Prentice-Hall, 1995.
;-----------------------------------------------------------
MsToMicro = 1000000; convert ms to microseconds
ClockFrequency = 15085; microseconds per tick
.code
pushad
; Convert milliseconds to microseconds.
mov ebx,MsToMicro
mul ebx
; Divide by clock frequency of 15.085 microseconds,
; producing the counter for port 61h.
mov ebx,ClockFrequency
div ebx; eax = counter
mov ecx,eax
; Begin checking port 61h, watching bit 4 toggle
; between 1 and 0 every 15.085 microseconds.
L1:
in al,61h; read port 61h
and al,10h; clear all bits except bit 4
cmp al,ah; has it changed?
je L1; no: try again
mov ah,al; yes: save status
dec ecx
cmp ecx,0; loop finished yet?
ja L1
quit:
popad
ret
Delay ENDP
and then in your main Procedures just call it like
mov, 1000 ( 1 second )
call delay
2006-08-19 02:29:20
·
answer #6
·
answered by Nestor 4
·
0⤊
1⤋