di2778.txt :************************************************************************************************** ; LISTING 1 - ROUTINE FOR MULTIFUNCTIONAL OPERATION ; ; "Microcontroller becomes multifunctional," EDN, Oct 25, 2001, pg 90 ; ;************************************************************************************************* 1 *********** Multifunctional operation *********** 0000 2 $include "std-j1a.asm" ; 0000 3 $PAGEWIDTH 160 07F1 4 org MOR; resistor osc and input pulldown 07F1 20 5 fcb %00100000; 6 ****** I/O PORT BITS ***************************** 07F2 7 start equ pA0 07F2 8 rate equ pA1 07F2 9 pulse equ pA4 07F2 10 LED equ pA5 11 ********** CONSTANTS ***************************** 07F2 12 N1 equ 16T ;rate 65.5ms x16=1sec 07F2 13 N2 equ 64T ;rate 65.5ms x64=4sec 14 ********** VARIABLES ***************************** 00C0 15 org RAM 00C0 16 N rmb 1 ; time counter 17 ****** INITIALIZATION *********************** 0300 18 org ROM 0300 [02] A630 19 init lda #%00110000 ;set I/O prtA 0302 [04] B704 20 sta ddrA 0304 [05] 3F00 21 clr prtA ;all output devices off 0306 [05] 3FC0 22 clr N 0308 [02] 9A 23 cli ;Interrupt enable 24 ************************************************* 0309 [05] 0100FD 25 MAIN: brclr start,prta,main ;wait for start 030C [05] 1808 26 bset RTIE,TSCR ;start pulse generating 030E [05] 1A00 27 bset LED,prtA ;set LED on 0310 [02] 9D 28 work nop ;this instruction for illustration only 29 ; perform some other operations 30 ; 0311 [05] 0000FC 31 brset start,prtA,work ;continue pulse generating ? 0314 [05] 1908 32 bclr RTIE,TSCR ;stop pulse generating 0316 [05] 1B00 33 bclr LED,prtA ;set LED off 34 ;perform some other operations 35 ; 0318 [03] 20EF 36 bra MAIN uC multifunct.asm Assembled with CASMW 07/11/2001 11:38:39 AM PAGE 2 37 * Real Time Interrupt Service routine 38 ******************************************************* 031A [05] 3CC0 39 RTI inc N ;N + 1 031C [03] B6C0 40 lda N 031E [05] 030010 41 brclr rate,prtA,rN1 ;if rate=0,go to rN1 0321 [03] B140 42 cmp N2 0323 [03] 2509 43 blo res 0325 [05] 3FC0 44 pls clr N 0327 [05] 1800 45 bset pulse,prtA ;generate one pulse 0329 [06] CD0337 46 jsr dly25ms ; with 25 ms width 032C [05] 1900 47 bclr pulse,prtA ; 032E [05] 1408 48 res bset RTIFR,TSCR ;RTIF reset 0330 [09] 80 49 rti ;return from Real Time Interrupt 0331 [03] B110 50 rN1 cmp N1 0333 [03] 25F9 51 blo res 0335 [03] 20EE 52 bra pls 53 ******************************************************** 0337 [02] A620 54 dly25ms lda #32T ;25ms delay 0339 [03] 5F 55 lp1 clrx 033A [03] 5A 56 lp2 decx 033B [03] 26FD 57 bne lp2 033D [03] 4A 58 deca 033E [03] 26F9 59 bne lp1 0340 [06] 81 60 rts 61 ********************************************** 07F8 62 org VECTORS 07F8 031A 63 fdb RTI 07FE 64 org VECTORS+6 07FE 0300 65 fdb init