AS11, an absolute assembler for Motorola MCU's, version 1.2e

                        *
                        * 5s_delay.asm  5 second delay timer for FOX11 board
                        *               with Wytec Phantom Monitor (c)2003, EVBplus.com
                        *               Written By Wayne Chu
                        *
                        *     Function:	5 second delay routine using output comparator OC2
                        *		The PB5 LED will be turned on immediately after running
                        *		the program. It will be turned off after 5 second delay. 
                        *		Change the DELAY_TIME to 18000 will delay 3 minutes
                        *
0040                    DB6:		equ	$40
0020                    PB5:		equ	$20
00bf                    NOTDB6		equ	$BF
1404                    portb:  	equ     $1404 		; 74HC273 latch
                        *
                        * 68HC11 control register address is the offset address from the
                        * register base address $1000, so index addressing mode can also be used.
                        *
0018                    toc2:   	equ     $0018
0022                    tmsk1:		equ	$0022
0023                    tflg1:		equ	$0023	
1000                    REGBLK:		equ	$1000
0880                    WYTEC_MON:	equ	$0880		; WYTEC monitor re-entry point	
                        *
                        *DELAY_TIME:	equ	18000		; 18000 X 10 ms= 180 sec = 3 min
01f4                    DELAY_TIME:	equ	500		; 500 X 10 ms= 5 sec
4e20                    TB10MS:		equ	20000		; time base of 20,000 instruction cycles
                        *					; = 20,000 x 0.5us = 10ms at 8MHz
                        
0040                    		org	$40
                        *
0040                    flag_5s:	rmb	1
0041                    cnt_5s:		rmb	2
0043                    d10ms_flag:	rmb	1
                        *
00ff                    STACK:		equ	$FF
                        *
f000                    		org	$F000
f000                    start:
f000 8e 00 ff           		lds	#STACK
f003 ce 10 00           		ldx	#REGBLK
f006 86 40              		ldaa	#DB6	
f008 a7 22              		staa	tmsk1,x
f00a 0e                 		cli
f00b 86 20              		ldaa	#PB5
f00d b7 14 04           		staa	portb		; turn on LED PB5
f010 bd f0 1b           		jsr	delay_5s
f013 86 01              		ldaa	#1
f015 b7 14 04           		staa	portb		; turn off LED PB5, but keep LED PB0 on
                        *
f018 7e 08 80           		jmp	WYTEC_MON	; re-enter Wytec monitor
                        *
f01b 7f 00 41           delay_5s: 	clr	cnt_5s
f01e 7f 00 42           		clr	cnt_5s+1
f021 7f 00 40           		clr	flag_5s
f024 96 40              delay:		ldaa	flag_5s
f026 27 fc              		beq	delay
f028 39                 		rts
                        *
f029 de 41              tmr6oc2: 	ldx	cnt_5s
f02b 08                 		inx
f02c df 41              		stx	cnt_5s
f02e 8c 01 f4           		cpx	#DELAY_TIME
f031 26 0a              		bne	tmr6
f033 7f 00 41           		clr	cnt_5s
f036 7f 00 42           		clr	cnt_5s+1
f039 86 01              		ldaa	#1
f03b 97 40              		staa	flag_5s
                        
                        * in an interrupt servicing routine the x register will be saved automatically
                        * the rti instruction will pop the x register off stack.
                        *
f03d ce 10 00           tmr6:	        ldx	#REGBLK	
f040 cc 4e 20           		ldd	#TB10MS			; reload the count for 10 ms time base
f043 e3 18              		addd	toc2,x
f045 ed 18              		std	toc2,x
f047 1d 23 bf           		bclr	tflg1,x NOTDB6		; clear flag
f04a 3b                 		rti
                        *
ffe6                    		org	$FFE6
ffe6 f0 29              		fdb	tmr6oc2
fffe                    		org	$FFFE
fffe f0 00              		fdb	start
                        		end
                        
                        
                        

Executed: Sat Dec 31 02:26:13 2005
Total cycles: 135, Total bytes: 79
Total errors: 0, Total warnings: 0
