|
Tomas,
NOP is the easiest way while staying within a single program. If you want to
measure long periods of time, you could attach some code to the 2khz
interrupt timer (documented in the handyboard manual). Just setup a memory
space to use as a counter and in that 2khz code, decrement the value at that
memory until it reaches zero. That's the most effective way to measure long
periods with the handyboard without trying to use another output compare
timer, because they aren't well-documented as to what is in use already.
Below is some code I wrote to disable robots after exactly 2 minutes of
competition, I hope it helps.
-Craig Morin
Teaching Assistant
Fundamentals of Engineering for Honors (program name change since my last
post, same acronym)
The Ohio State University
********************************
* Competition Timer for the 2002
* Freshman Engineering Honors Program
* The Ohio State University
*
* Written by Craig Morin
********************************
********************************
* EQUs
********************************
DIV1 EQU 1000 ; divider to get 1khz down to 1hz
DIV2 EQU 120 ; Number of seconds to count
BASE EQU $1000 ; register base
PACTL EQU $1026 ; Pulse Accumulator Control register
TOC4INT EQU $E2 ; Timer Output Compare 4
TMSK1 EQU $1022 ; main Timer interrupt Mask register 1
********************************
* Program Origin and Variables
********************************
ORG MAIN_START
intdiv1 FDB DIV1 ; Memory to hold 1khz divider count
intdiv2 FDB DIV2 ; Memory to hold seconds count
enable FDB 0 ; Memory for count enable flag
********************************
* Program init
********************************
* install module into 1 kHz IC system interrupt on TOC4
subroutine_initialize_module:
LDX #$BF00 ; pointer to interrupt base
* install ourselves onto system interrupt
* get current vector; poke such that when we finish, we go there
LDD TOC4INT,X ; SystemInt on TOC4
STD interrupt_code_exit+1
* install ourself as new vector
LDD #interrupt_code_start
STD TOC4INT,X
* initialize interrupt dividers
LDD #DIV1
STD intdiv1 ; intdiv1 = DIV1
LDD #DIV2
STD intdiv2 ; intdiv2 = DIV2
* initialize enable
LDX #0
STX enable ; enable = 0
RTS
********************************
* C-Accessable function to enable the countdown
********************************
* called like: start_competition(#); where # is any number
subroutine_start_competition:
LDAA #$01
STAA enable
RTS
********************************
* Interrupt Code
********************************
interrupt_code_start:
* test for timer enabled
TST enable
BEQ interrupt_code_exit ; exit when enable=0
* decrement and store divider 1
LDX intdiv1
DEX
STX intdiv1
BNE interrupt_code_exit ; exit when intdiv1 > 0
* reload divider 1
LDX #DIV1
STX intdiv1 ; intdiv1 = DIV1
* decrement and store divider 2
LDX intdiv2
DEX
STX intdiv2
BNE interrupt_code_exit ; exit when intdiv2 > 0
* load 1 into each divider
* so next interrupt we break through the
* decrement code and get back here
LDX #1
STX intdiv1
STX intdiv2 ; intdiv1 = intdiv2 = 1
* servos off
LDX #BASE
BCLR PACTL,X $80 ; turn a5 pin to input to disable servo
BCLR TMSK1,X $A0 ; disable both the a5 and a7 interrupts
* motor off
LDAA #0
STAA $0E ; store 0 in motor control byte
********************************
* Interrupt Code Exit
********************************
interrupt_code_exit:
JMP $0000 ; this value poked in by init routine
"Tomas Carlsson" <Tomas.Carlsson@summus.com> wrote in message
news:71E038F7F1BE274CB819A9E6004F489DA56E6A@summusmail.summuslan.com...
Hello,
Is there any other way, than using NOP repeated times, to create time
delays in assembler?
Regards,
Tomas
--
MIME ATTACHMENTS DISCARDED:
1. Content-Type: text/html;
charset=so-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Length: 627
|
|
Message is in Reply To:
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|