Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 1 0000 1 $BASE 10T 2 ;*************************************************** *********************** 3 ; "EXERCISER" 4 ; DIGITAL QRP BREADBOARD 5 ; 6 ; Version 1.0 04/10/2003 7 ; 8 ; George Heron, N2APB 9 ; 2419 Feather Mae Ct. 10 ; Forest Hill, MD 21050 11 ; email: n2apb@amsat.org 12 ; 13 ; This program is the initial application that comes pre-loaded on the HC908 Daughtercard. 14 ; It sits in "User Application" area of memory ($8000-$EEFF) and co-resides 15 ; with the HCmon debug monitor also on the Daughterc ard (at $EF00-$FFDE). 16 ; 17 ; "Exerciser" is a simple application that is controlled via the RS-232 serial port 18 ; and is used to demonstrate use of typical I/O peripherals one might use with the 19 ; processor. Exerciser provides a set of library routines and drivers for the various 20 ; hardware components comprising the Digital Breadboard project: LCD, keypad, 21 ; DDS, A/D Converter, shaft encoder and EEPROM. These library routines 22 ; are individually selectable from a menu presented sent to the serial 23 ; port, allowing the user to invoke any of the functions for test purposes. 24 ; Further, the user may conveniently modify the Exerciser program to serve as the starting 25 ; point for custom program development. 26 ; 27 ; For complete documentation and design details, see the web pages devoted for this 28 ; project at www.njqrp.org/hc908_resource_page 29 ; 30 ; This code is intended to run on a Motorola 68HC908AB32 microcontroller and is 31 ; best assembled within the Integrated Development Environment editor, provided free 32 ; by Motorola as part of their HC908 development tool suite. See the HC908 Resource Page 33 ; for full details on obtaining this development software. 34 ; 35 ; Revision History: 36 ; ---------------- 37 ; 1.0 04/10/2003 Initial release 38 ; 39 ;*************************************************** *********************** 40 ; Copyright 2003 by G. Heron, N2APB. All rights Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 2 reserved. For personal, non-profit use only. 41 ;*************************************************** *********************** 42 0000 43 include "../AB_REGS.INC" ;MC68HC908GP32 register defimitions 44 ; 68HC908AB32 Equates 45 0000 46 PTA EQU $0000 ; Ports and data direction 0000 47 PORTA EQU $0000 0000 48 PTB EQU $0001 0000 49 PORTB EQU $0001 0000 50 PTC EQU $0002 0000 51 PORTC EQU $0002 0000 52 PTD EQU $0003 0000 53 PORTD EQU $0003 0000 54 DDRA EQU $0004 0000 55 DDRB EQU $0005 0000 56 DDRC EQU $0006 0000 57 DDRD EQU $0007 58 0000 59 PTE EQU $0008 0000 60 PORTE EQU $0008 0000 61 PTF EQU $0009 0000 62 PORTF EQU $0009 0000 63 PTG EQU $000A 0000 64 PORTG EQU $000A 0000 65 PTH EQU $000B 0000 66 PORTH EQU $000B 67 0000 68 DDRE EQU $000C 0000 69 DDRF EQU $000D 0000 70 DDRG EQU $000E 0000 71 DDRH EQU $000F 72 73 ;* Serial Peripheral Interface Module (SPI) ******************************** 74 0000 75 spcr equ $10 ; SPI Control Register 0000 76 SPRIE equ 7 ; SPI receiver interrupt enable bit 0000 77 SPMSTR equ 5 ; SPI master bit 0000 78 CPOL equ 4 ; clock polarity bit 0000 79 CPHA equ 3 ; clock phase bit 0000 80 SPWOM equ 2 ; SPI wired-or mode bit 0000 81 SPE equ 1 ; SPI enable 0000 82 SPTIE equ 0 ; SPI transmit interrupt enable 83 0000 84 spscr equ $11 ; SPI Status and Control Register 0000 85 SPRF equ 7 ; SPI receiver full bit Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 3 0000 86 ERRIE equ 6 ; error interrupt enable bit 0000 87 OVRF equ 5 ; overflow bit 0000 88 MODF equ 4 ; mode fault bit 0000 89 SPTE equ 3 ; SPI transmitter empty bit 0000 90 MODFEN equ 2 ; mode fault enable bit 0000 91 SPR1 equ 1 ; SPI baud rate 0000 92 SPR0 equ 0 ; select bits 93 0000 94 spdr equ $12 ; SPI Data Register 95 96 97 ;* Serial Communications Interface (SCI) ********* ************************* 98 0000 99 scc1 equ $13 ; SCI Control Register 1 0000 100 LOOPS equ 7 ; loop mode select bit 0000 101 ENSCI equ 6 ; enable SCI bit 0000 102 TXINV equ 5 ; transmit inversion bit 0000 103 M equ 4 ; mode bit 0000 104 WAKE equ 3 ; wakeup condition bit 0000 105 ILTY equ 2 ; idle line type bit 0000 106 PEN equ 1 ; parity enable bit 0000 107 PTY equ 0 ; parity bit 108 0000 109 scc2 equ $14 ; SCI Control Register 2 0000 110 SCTIE equ 7 ; SCI transmit interrupt enable bit 0000 111 TCIE equ 6 ; transmissi on complete int enable bit 0000 112 SCRIE equ 5 ; SCI receive interrupt enable bit 0000 113 ILIE equ 4 ; idle line interrupt enable bit 0000 114 TE equ 3 ; transmitte r enable bit 0000 115 RE equ 2 ; receiver enable bit 0000 116 RWU equ 1 ; receiver wakeup bit 0000 117 SBK equ 0 ; send break bit 118 Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 4 0000 119 scc3 equ $15 ; SCI Control Register 3 0000 120 R8 equ 7 ; received bit 8 0000 121 T8 equ 6 ; transmitte d bit 8 0000 122 ORIE equ 3 ; receiver overrun interrupt enable bit 0000 123 NEIE equ 2 ; receiver noise error int enable bit 0000 124 FEIE equ 1 ; receiver framing error int enable bit 0000 125 PEIE equ 0 ; receiver parity error int enable bit 126 0000 127 scs1 equ $16 ; SCI Status Register 1 0000 128 SCTE equ 7 ; SCI transmitter empty bit 0000 129 TC equ 6 ; transmissi on complete bit 0000 130 SCRF equ 5 ; SCI receiver full bit 0000 131 IDLE equ 4 ; receiver idle bit 0000 132 OR equ 3 ; receiver overrun bit 0000 133 NF equ 2 ; receiver noise flag bit 0000 134 FE equ 1 ; receiver framing error bit 0000 135 PE equ 0 ; receiver parity error bit 136 0000 137 scs2 equ $17 ; SCI Status Register 2 0000 138 BKF equ 1 ; break flag bit 0000 139 RPF equ 0 ; reception in progress flag bit 140 ; 0000 141 scdr equ $18 ; SCI Data Register 0000 142 scbr equ $19 ; SCI Baud Rate Register 143 144 145 ;* External Interrupt (IRQ) ********************** ************************* 146 0000 147 intscr equ $1D ; IRQ Status and Control Register 0000 148 IRQF equ 3 ; IRQ flag bit 0000 149 ACK equ 2 ; IRQ interrupt request acknowledge bit 0000 150 IMASK equ 1 ; IRQ interrupt mask bit Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 5 0000 151 MODE equ 0 ; IRQ edge/level select bit 152 0000 153 ISCR EQU $001A 154 155 156 ;* Keyboard Interrupt Module (KBI) *************** ************************* 157 0000 158 intkbscr equ $1B ; Keyboard Status and Control Register 0000 159 KBSCR EQU $001B 0000 160 KEYF equ 3 ; keyboard flag bit 0000 161 ACKK equ 2 ; keyboard acknowledge bit 0000 162 IMASKK equ 1 ; keyboard interrupt mask bit 0000 163 MODEK equ 0 ; keyboard triggering sensitivity bit 164 ; 0000 165 intkbier equ $21 ; Keyboard Interrupt Enable Register 0000 166 KBICR EQU $0021 0000 167 KBIE4 equ 4 0000 168 KBIE3 equ 3 0000 169 KBIE2 equ 2 0000 170 KBIE1 equ 1 0000 171 KBIE0 equ 0 172 173 174 ;* Clock Generator Module (CGMC) ***************** ************************* 175 0000 176 pctl equ $1C ; PLL Control Register 0000 177 PLLIE equ 7 ; PLL interrupt enable bit 0000 178 PLLF equ 6 ; PLL interrupt flag bit 0000 179 PLLON equ 5 ; PLL on bit 0000 180 BCS equ 4 ; base clock select bit 181 ; 0000 182 pbwc equ $1D ; PLL Bandwidth Control Register 0000 183 AUTO equ 7 ; automatic bandwidth control bit 0000 184 LOCK equ 6 ; lock indicator bit 0000 185 ACQ equ 5 ; acquisitio n mode bit 186 0000 187 PPG equ $001E ; PLL Programmin g Register 188 ; Multiplier Select bits [7:4] 189 ; VCO Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 6 Frequency Multiplier bit [3:0] 190 191 ;* Configuration Registers (CONFIG) ************** ************************* 192 0000 193 CONFIG EQU $001F ; System configuration 0000 194 CONFIG1 EQU $001F 0000 195 CONFIG2 EQU $003F 196 0000 197 TASC EQU $0020 ; Timer A 0000 198 TACNTH EQU $0022 0000 199 TACNTL EQU $0023 0000 200 TAMODH EQU $0024 0000 201 TAMODL EQU $0025 0000 202 TASC0 EQU $0026 0000 203 TACH0H EQU $0027 0000 204 TACH0L EQU $0028 0000 205 TASC1 EQU $0029 0000 206 TACH1H EQU $002A 0000 207 TACH1L EQU $002B 0000 208 TASC2 EQU $002C 0000 209 TACH2H EQU $002D 0000 210 TACH2L EQU $002E 0000 211 TASC3 EQU $002F 0000 212 TACH3H EQU $0030 0000 213 TACH3L EQU $0031 214 0000 215 TBSC EQU $0041 ; Timer B 0000 216 TBCNTH EQU $0042 0000 217 TBCNTL EQU $0043 0000 218 TBMODH EQU $0044 0000 219 TBMODL EQU $0045 0000 220 TBSC0 EQU $0046 0000 221 TBCH0H EQU $0047 0000 222 TBCH0L EQU $0048 0000 223 TBSC1 EQU $0049 0000 224 TBCH1H EQU $004A 0000 225 TBCH1L EQU $004B 0000 226 TBSC2 EQU $0032 0000 227 TBCH2H EQU $0033 0000 228 TBCH2L EQU $0034 0000 229 TBSC3 EQU $0035 0000 230 TBCH3H EQU $0036 0000 231 TBCH3L EQU $0037 232 0000 233 TSC EQU $004B ; Timer 0000 234 TCNTH EQU $004C 0000 235 TCNTL EQU $004D 0000 236 TMODH EQU $004E 0000 237 TMODL EQU $004F 238 239 240 241 ;* Analog-to-Digital Converter (ADC) ************* ************************* 242 0000 243 adscr equ $38 ; ADC Status and Control Register Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 7 0000 244 COCO equ 7 ; conversion s complete flag 0000 245 AIEN equ 6 ; ADC interrupt enable bit 0000 246 ADCO equ 5 ; ADC continuous conversion bit 0000 247 ADCH4 equ 4 ; \ 0000 248 ADCH3 equ 3 ; \ 0000 249 ADCH2 equ 2 ; ADC channel select bits 0000 250 ADCH1 equ 1 ; / 0000 251 ADCH0 equ 0 ; / 252 0000 253 adr equ $39 ; ADC Data Register 254 0000 255 adclk equ $3A ; ADC Clock Register 0000 256 ADIV2 equ 7 ; \ 0000 257 ADIV1 equ 6 ; ADC clock prescaler bits 0000 258 ADIV0 equ 5 ; / 0000 259 ADICLK equ 4 ; ADC input clock select bit 260 261 ;* Pullup Registers ******************************* ******* 262 0000 263 PTDPUE EQU $003D 0000 264 PTFPUE EQU $003E 0000 265 PRTFPU EQU $003E 266 267 ;* System Integration Module (SIM) *************** ************************* 268 0000 269 sbsr equ $FE00 ; SIM Break Status Register 0000 270 SBSW equ 1 ; SIM break stop/wait 271 0000 272 srsr equ $FE01 ; SIM Reset Status Register 0000 273 POR equ 7 ; power-on reset bit 0000 274 PIN equ 6 ; external reset bit 0000 275 COP equ 5 ; COP reset bit 0000 276 ILOP equ 4 ; illegal opcode reset bit 0000 277 ILAD equ 3 ; illegal opcode address reset bit 278 ;MODRST equ 2 ; monitor mode entry module reset bit 0000 279 LVI equ 1 ; LVI reset bit 280 0000 281 sbfcr equ $FE03 ; SIM Break Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 8 Flag Control Register 0000 282 BCFE equ 7 ; break clear flag enable bit 283 284 ;* Flash Memory ********************************** ************************* 285 0000 286 flcr equ $FE08 ; Flash Control Register 0000 287 HVEN equ %00001000 ; high-voltage enable bit mask 0000 288 MASS equ %00000100 ; mass erase control bit mask 0000 289 ERASE equ %00000010 ; erase control bit mask 0000 290 PGM equ %00000001 ; program control bit mask 291 0000 292 flbpr equ $FF7E ; Flash Block Protect Register 293 294 ;* Breakpoint Module (BRK) *********************** ************************* 295 0000 296 brkh equ $FE0C ; Break Address Register High 0000 297 brkl equ $FE0D ; Break Address Register Low 0000 298 brkscr equ $FE0E ; Break Status and Control Register 0000 299 BRKE equ 7 ; break enable bit 0000 300 BRKA equ 6 ; break active bit 301 302 ;* Low-Voltage Inhibit (LVI) ********************* ************************* 303 0000 304 lvisr equ $FE0F ; LVI Status Register 0000 305 LVIOUT equ 7 ; LVI output bit 306 307 ;* EEPROM programming registers ******************* *************************** 308 0000 309 EEDIVHNVR equ $FE10 310 0000 311 EEDIVLNVR equ $FE11 312 0000 313 EEDIVH equ $FE1A 314 0000 315 EEDIVL equ $FE1B 316 0000 317 eenvr equ $FE1C ;EEPROM Array Config Reg 0000 318 EEPRTCT equ 16 ;protection bit Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 9 0000 319 EEBP3 equ 8 ;block potection bit 3 0000 320 EEBP2 equ 4 ;block potection bit 2 0000 321 EEBP1 equ 2 ;block potection bit 1 0000 322 EEBP0 equ 1 ;block potection bit 0 323 0000 324 eecr equ $FE1D ;EEPROM Control Reg 0000 325 EEDUM equ 128 ;dummy bit 0000 326 EEOFF equ 32 ;power off 0000 327 EERAS1 equ 16 ;erase/program mode select bit 1 0000 328 EERAS0 equ 8 ;erase/program mode select bit 0 0000 329 EELAT equ 4 ;latch control 0000 330 EEAUTO equ 2 ;automatic termination of prgm/erase cycle 0000 331 EEPGM equ 1 ;program/erase enable 332 0000 333 EEACR equ $FE1F 334 335 ;* Computer Operating Properly (COP) ************* ************************* 336 0000 337 copctl equ $FFFF ; COP Control Register 338 339 ;*************************************************** ********* 340 ; VECTORS 341 ;*************************************************** ********* 342 0000 343 dbg_vectors equ $FAD0 ; Debug Vectors 344 0000 345 Vectors: equ $ffd0 346 0000 347 ivadc: equ $ffd0 ; Vector for A/D conversion Complete 0000 348 ivkey: equ $ffd2 ; Vector for Keyboard 0000 349 ivsctx: equ $ffd4 ; Vector for SCI Tx 0000 350 ivscrx: equ $ffd6 ; Vector for SCI Rx 0000 351 ivscer: equ $ffd8 ; Vector for SCI Error 0000 352 equ $ffda ; Reserved 0000 353 equ $ffdc ; Reserved 0000 354 ivtb3: equ $ffde ; TIMB Channel 3 Vector 0000 355 ivtb2: equ $ffe0 ; TIMB Channel 2 Vector Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 10 0000 356 ivsptx: equ $ffe2 ; Vector for SPI Tx 0000 357 ivsprx: equ $ffe4 ; Vector for SPI Rx 0000 358 ivtbof: equ $ffe6 ; TIMB Overflow Vector 0000 359 ivtb1: equ $ffe8 ; TIMB Channel 1 Vector 0000 360 ivtb0: equ $ffea ; TIMB Channel 0 Vector 0000 361 ivtao: equ $ffec ; TIMA Overflow Vector 0000 362 ivt1c1: equ $ffee ; TIMA Channel 3 Vector 0000 363 ivta2: equ $fff0 ; TIMA Channel 2 Vector 0000 364 ivta1: equ $fff2 ; TIMA Channel 1 Vector 0000 365 ivta0: equ $fff4 ; TIMA Channel 0 Vector 0000 366 ivtof: equ $fff6 ; TIM Overflow Vector 0000 367 ivpll: equ $fff8 ; PLL Vector 0000 368 ivirq: equ $fffa ; ~IRQ1 Vector 0000 369 ivswi: equ $fffc ; SWI Vector 0000 370 ivrst: equ $fffe ; Reset Vector 371 372 373 ;*************************************************** ********* 374 ;* Memory Map 375 ;*************************************************** ********* 376 0000 377 ram_start equ $0050 ; start of RAM 0000 378 zpage_end equ $00FF ; End of zero page ram 0000 379 extraram equ $0100 ; Start of Extra RAM 0000 380 usr_stack equ $01ff ; Bottom of user stack 0000 381 ram_last equ $023F ; last RAM location 0000 382 rom_start equ $8000 ; start of ROM 0000 383 rom_last equ $FAFF ; last ROM location ($FDFF??) 384 385 386 ;(C)opywrite P&E Microcomputer Systems, 2000 (www.pemicro.com) 387 ; You may use this code freely as long as this copyright notice 388 ; and website address is included and un-modified. 389 0000 390 include "../macros.inc" ;Macro instruction definition 391 ; -------------------------------------------------- ----------------- 392 ; Macro Definitions 393 ; -------------------------------------------------- Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 11 ----------------- 394 0000 395 #macro aax macro 396 psha 397 pshx 398 add 1,sp 399 pulx 400 tax 401 bcc *+7 ; Branch to below 402 pshh 403 inc 1,sp 404 pulh 405 ; Branch to here 406 pula 0000 407 #macroend 408 0000 409 #macro inch macro 410 pshh 411 inc 1,sp 412 pulh 0000 413 #macroend 414 0000 415 #macro tha macro 416 pshh 417 pula 0000 418 #macroend 419 0000 420 #macro tah macro 421 psha 422 pulh 0000 423 #macroend 424 0000 425 #macro pshhx macro 426 pshx 427 pshh 0000 428 #macroend 429 0000 430 #macro pulhx macro 431 pulh 432 pulx 0000 433 #macroend 434 0000 435 #macro ldhxx macro 436 lda ,x 437 ldx 1,x 438 psha 439 pulh 0000 440 #macroend 441 0000 442 include "../local.inc" ;Local system variables 443 ; 444 ; Conditional Assembly Directives *************** ************************* 445 ; 446 0000 447 #setnot HYPERTERM ; enable slow Hyperterminal communications Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 12 448 449 ; 450 ; Microcontroller Peripheral Equates ************ ************************* 451 ; 452 0000 453 boot_start equ $E000 ; start of protected Bootloader 0000 454 flash_protect equ {(boot_start>7)&$FF} ; Flash Block Protect Reg value 0000 455 flash_page equ 128T ; Flash Erase Page size 456 0000 457 init_config1 equ %00000011 ; initial Configurat ion Register 1 458 ; Bit_7=0 - LVISTOP - LVI disabled during stop mode 459 ; Bit_6 unused 460 ; Bit_5=0 - LVIRSTD - LVI reset enabled during run mode 461 ; Bit_4=0 - LVIPWRD - Power enabled to LVI module 462 ; Bit_3=0 - SSREC - Stop recovery after 4096 cycles 463 ; Bit_2=0 - COPRS - COP rate (2**18 - 2**4) 464 ; Bit_1=1 - STOP - Stop Instruction disabled 465 ; Bit_0=1 - COPD - COP Disabled 466 ; 0000 467 RXBLEN equ 14T ; Serial I/O Receive buffer length 0000 468 STACK_ALLOC equ 32T ; Monitor Stack Allocation 469 ; 0000 470 init_scc1 equ %01000000 ; enable SCI, 8-bits, no par, 1 stop 0000 471 init_scc2 equ %00001100 ; no interupts, rcvr and tmtr enabled 0000 472 init_scbr equ %00000011 ; set SCI for 9600 baud 473 ; 474 ; ASCII character definitions 475 0000 476 SPACE equ $20 ; ASCII space 0000 477 CR equ $0D ; ASCII carriage return 0000 478 LF equ $0A ; ASCII linefeed 0000 479 NUL equ $00 ; ASCII linefeed 0000 480 BS equ $08 ; ASCII Backspace key 0000 481 XOFF equ $13 ; ASCII X-Off key (^S or DC3) 0000 482 XON equ $11 ; ASCII X-On key (^S or DC1) 0000 483 ESC equ $1B ; ASCII Escape Character 484 485 ;--------------------------------------------------- ---- Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 13 486 ; TIMING FOR fbus = 0.407 us 487 ;the internal clock fBUS runs at 1/2.4576 ^6 = 0.407 uS. 488 ;The DBNZ instruction takes 3 cycles, which makes 1.22 uS 489 ;us5 EQU 5 ;5 * 1.22 = 6.1 uS 490 ;us10 EQU 9 ;9 * 1.22 = 10.9 uS 491 ;us30 EQU 25 ;25 * 1.22 = 30.5 uS 492 ;us100 EQU 82 ;82 * 1.22 = 100 493 ;ms1 EQU 10 ;10 * 82 * 1.22 = 1.00 mS 494 495 ;--------------------------------------------------- ----- 496 ; TIMING FOR fbus = 0.115 us 497 ;The DBNZ instruction takes 3 cycles, which makes 0.344 uS 0000 498 us1 EQU 3 ;3 * 0.344 = 1.032 uS 0000 499 us5 EQU 18 ;18 * 0.344 = 6.1 uS 0000 500 us10 EQU 32 ;32 * 0.344 = 10.9 uS 0000 501 us30 EQU 89 ;89 * 0.344 = 30.5 uS 0000 502 us50 EQU 148 ;148 * 0.344 = 51 us 0000 503 ms1 EQU 36 ;36 * 82 * 0.344 = 1.00 mS 504 0000 505 tpgs EQU us5 ;times taken from MC68HC908AB32/D rev 1 0000 506 tnvs EQU us10 0000 507 tprog EQU us30 0000 508 tnvh EQU us5 0000 509 terase EQU ms1 510 0000 511 RAMStart equ $0053 ;User App RAM is from 53 to 3FF. (HCmon RAM from 400-44F) 0000 512 EEPROM equ $800 ;EEPROM mem is 800-9FF (512 bytes) 0000 513 RomStart equ $8000 ;Flash mem is 8000 to FFFF (32 MB) 514 515 ;Port A pin usage 0000 516 LCD_e equ 3 ;LCD enable = bit 3 of porta 0000 517 LCD_rw equ 2 ;LCD read/write. 0=write, 1=read 0000 518 LCD_rs equ 1 ;LCD register select. 0=instruction, 1=data 519 520 ;Port B pin usage 0000 521 Reflect-FWD equ 2 ;Reflectometer Forward Voltage 0000 522 Reflect-REF equ 1 ;Reflectometer Reflected Voltage 0000 523 Reflect-Z equ 0 ;Reflectometer Impedance Voltage Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 14 524 525 ;Port C Usage 0000 526 Dah equ 5 ;Dah paddle input 0000 527 Dit equ 2 ;Dit paddle input 0000 528 Keyline equ 1 ;Keyline control to transmitter 0000 529 FreqCntr equ 0 ;Frequency counter input 530 531 ;Port D pin usage 0000 532 Tones equ 2 ;Tones signal to audio amp 533 534 ;Port E Usage 0000 535 Piezo equ 2 ;Piezo sounder 0000 536 RxData equ 1 ;serial port receive 0000 537 TxData equ 0 ;serial port transmit 538 539 ;PortF pin usage 0000 540 Mon_Jumper equ 7 ;Monitor jumper 0000 541 HeartbeatLED equ 6 ;Heartbeat LED 0000 542 ENC_A equ 5 ;Encoder-A pin 0000 543 ENC_B equ 4 ;Encoder-B pin 0000 544 ENC_pb equ 3 ;Encoder-Pushbutto n pin 0000 545 DDS_load equ 2 ;DDS load pin 0000 546 DDS_clk equ 1 ;DDS clock pin 0000 547 DDS_data equ 0 ;DDS data pin 548 0053 549 org RamStart 550 0053 551 _hbufpos rmb 2 ;buffer position temp storage 552 0055 553 Timeout1 ds 1 ;Allows three timeout routines to be called each of which 0056 554 Timeout2 ds 1 ;can run for up to ~ 1/2 second. 0057 555 Timeout3 ds 1 556 0058 557 Piezo_temp ds 1 ;piezo temp variable 558 0059 559 Enc_tens ds 1 ;encoder display digit (tens) 005A 560 Enc_units ds 1 ;encoder display digit (ones) 561 005B 562 LCD_timer ds 1 ;counter for timeout check in LCD busy_check 005C 563 LCD_read ds 1 ;temp store for status read in LCD busy_check 005D 564 LCD_char ds 1 ;temp for LCD data written (cmnd2LCD & data2LCD) 005E 565 temp1 ds 1 ;temp store used in write_LCD Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 15 005F 566 temp2 ds 1 567 0060 568 temp ds 1 ;temp used in EEPROM driver 569 0061 570 enc_new ds 1 ;new reading of encoder 0062 571 enc_old ds 1 ;last reading of encoder 0063 572 enc_temp ds 1 ;temp location for encoder bits 0064 573 A_flag ds 1 ;enc line A hi/lo status 0065 574 B_flag ds 1 ;enc line B hi/lo status 575 0066 576 a2d_last ds 1 ;previous A/D reading 0067 577 a2d_lasta ds 1 ;previous A/D reading + 1 0068 578 a2d_lastb ds 1 ;previous A/D reading - 1 579 0069 580 bit_count ds 1 ;DDS bit counter 006A 581 byte_count ds 1 ;DDS byte counter 006B 582 byte2send ds 1 ;DDS byte to send 006C 583 DDS_w4 ds 1 ;DDS programming register W4 (freq-b7 ... freq-b0) 006D 584 DDS_w3 ds 1 ;DDS programming register W3 (freq-b15 ... freq-b8) 006E 585 DDS_w2 ds 1 ;DDS programming register W2 (freq-b23 ... freq-b16) 006F 586 DDS_w1 ds 1 ;DDS programming register W1 (freq-b31 ... freq-b24) 0070 587 DDS_w0 ds 1 ;DDS programming register W0 (phase-b4 ... control-0) 588 0071 589 count_lo ds 1 0072 590 count_hi ds 1 0073 591 to_addr ds 2 ;index pointer storage locs 0075 592 from_addr ds 2 593 0077 594 EEbyte_count ds 1 ;EEPROM byte counter 0078 595 EEline_count ds 1 ;EEPROM line counter 596 040A 597 org $040A ;common "_inbuf" buffer with HCmon 040A 598 _inbuf rmb RXBLEN ;Input Buffer 599 8000 600 org RomStart 601 602 ;*************************************************** *********************** 603 ; Vector Jump Table (located at start of User Area = 8000) Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 16 604 ;*************************************************** *********************** 605 8000 [03] CC8713 606 _user_adc jmp Dummy_ISR ; Insert jump to ADC vector code 8003 [03] CC8713 607 _user_keyboard jmp Dummy_ISR ; Insert jump to Keyboard vector code 8006 [03] CC8713 608 _user_scitx jmp Dummy_ISR ; Insert jump to SCI transmit vector code 8009 [03] CC8713 609 _user_scirx jmp Dummy_ISR ; Insert jump to SCI receive vector code 800C [03] CC8713 610 _user_scierr jmp Dummy_ISR ; Insert jump to SCI error vector code 800F [03] CC8713 611 _user_timbch3 jmp Dummy_ISR ; Insert jump to TIMB Channel 3 Vector code 8012 [03] CC8713 612 _user_timbch2 jmp Dummy_ISR ; Insert jump to TIMB Channel 2 Vector code 8015 [03] CC8713 613 _user_spitx jmp Dummy_ISR ; Insert jump to SPI transmit vector code 8018 [03] CC8713 614 _user_spirx jmp Dummy_ISR ; Insert jump to SPI receive vector code 801B [03] CC8713 615 _user_timb_of jmp Dummy_ISR ; Insert jump to TIMB Overflow Vector code 801E [03] CC8713 616 _user_timb_ch1 jmp Dummy_ISR ; Insert jump to TIMB Channel 1 Vector code 8021 [03] CC8713 617 _user_timb_ch0 jmp Dummy_ISR ; Insert jump to TIMB Channel 0 Vector code 8024 [03] CC8713 618 _user_tima_of jmp Dummy_ISR ; Insert jump to TIMA Overflow Vector code 8027 [03] CC8713 619 _user_tima_ch3 jmp Dummy_ISR ; Insert jump to TIMA Channel 3 Vector code 802A [03] CC8713 620 _user_tima_ch2 jmp Dummy_ISR ; Insert jump to TIMA Channel 2 Vector code 802D [03] CC86CE 621 _user_tima_ch1 jmp T_ISR ; Insert jump to TIMA Channel 1 Vector code 8030 [03] CC8713 622 _user_tima_ch0 jmp Dummy_ISR ; Insert jump to TIMA Channel 0 Vector code 8033 [03] CC8713 623 _user_tim_of jmp Dummy_ISR ; Insert jump to TIM Overflow Vector code 8036 [03] CC8713 624 _user_pll jmp Dummy_ISR ; Insert jump to PLL Vector code 8039 [03] CC8713 625 _user_irq jmp Dummy_ISR ; Insert jump to ~IRQ1 Vector code 626 803C [03] CC8622 627 _HCmon_LCD_disp jmp HCmon_LCD_disp ; vector (at $803C) for HCmon 628 ; to display message to LCD 629 630 ;*************************************************** *********************** 631 ;********************** USER APP ENTRY POINT ********************* 632 ;*************************************************** *********************** 633 ; This is the point ($8040) where User Code starts executing * 634 ; after coming from the Monitor "X" command Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 17 (eXecute User App) * 635 ; or after board gets a RESET (when Monitor jumper is off) * 636 ;*************************************************** *********************** 637 8040 638 org $8040 639 640 Start: 8040 [02] 9B 641 sei ;disable all interrupts 8041 [03] 4501FF 642 ldhx #$01FF ;initialize 8044 [02] 94 643 txs ; the stack pointer (why not 3FF?) 644 645 ;configure the output ports 8045 [04] 6EFC0C 646 mov #$FC,ddre ;set port E7-E2 as outputs 8048 [04] 6E470D 647 mov #$47,ddrf ;set port F6, F2-F0 as outputs 804B [04] 6EFE05 648 mov #$FE,ddrb ;set port B7-B1 as outputs 804E [04] 6E030F 649 mov #$03,ddrh ;set port H1-H0 as outputs 8051 [04] 6E070E 650 mov #$07,ddrg ;set port G2-G0 as outputs 8054 [04] 6EFF07 651 mov #$FF,ddrd ;set port D7-D0 as outputs 8057 [04] 6E3406 652 mov #$34,ddrc ;set port C5, C4 and C2 as outputs 653 654 ;initialize the output ports 805A [04] 6EFF01 655 mov #$FF,portb 805D [04] 6EFF02 656 mov #$FF,portC 8060 [04] 6EFF03 657 mov #$FF,portd 8063 [04] 6EFF08 658 mov #$FF,porte 8066 [04] 6EFF0A 659 mov #$FF,portg 8069 [04] 6EFF0B 660 mov #$FF,porth 806C [04] 1409 661 bset 2,portF 806E [04] 1209 662 bset 1,portf 8070 [04] 1009 663 bset 0,portf 664 8072 [03] B609 665 lda portf ;get initial encoder position 8074 [02] A430 666 and #$30 ;isolate the encoder bits 8076 [03] B762 667 sta enc_old ;initialize encoder old value 8078 [03] B761 668 sta enc_new ;initialize encoder new value 669 807A [04] 6EFF64 670 mov #$FF,A_flag 807D [04] 6EFF65 671 mov #$FF,B_flag 672 8080 [05] CD86BE 673 jsr Init_Timer 8083 [05] CD895F 674 jsr Init_EEPROM 8086 [03] 3F55 675 clr timeout1 ;init timeouts (0=off) Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 18 8088 [03] 3F56 676 clr timeout2 808A [03] 3F57 677 clr timeout3 808C [02] 9A 678 cli ;allow interrupts to happen 679 680 ;*************************************************** *********************** 681 ;***************** USER APPPLICATION MAINLINE ******************* 682 ;*************************************************** *********************** 683 684 User_Main: 808D [04] 6E0355 685 mov #3,timeout1 ;Start an A/D conversion in 3*2ms=6ms 686 8090 [05] CD8826 687 jsr LCD_init 688 8093 [04] C7FFFF 689 sta copctl ;clear the COP counter 690 8096 [02] A664 691 lda #100 8098 [05] CD8657 692 jsr delay 693 809B [03] 4580CC 694 ldhx #ExerciserBanner 809E [05] CD8A13 695 jsr _puts ;print Exerciser Banner message 80A1 [03] 45813D 696 ldhx #ExerciserMsg 80A4 [05] CD88E2 697 jsr disp_msg 698 80A7 [03] 45810A 699 um1: ldhx #Prompt 80AA [05] CD8A13 700 jsr _puts ;print prompt ("Exerciser> ") 80AD [05] CD89CB 701 jsr _gets ;get an input string 80B0 [03] 25F5 702 bcs um1 ;not valid char (ctl+C or ESC), try again 80B2 [04] C6040A 703 lda _inbuf ;get the character 80B5 [03] 27F0 704 beq um1 ;nothing entered (just ENTER), try again 80B7 [02] A4DF 705 and #$DF ;turn to capital letter 80B9 [03] 45814C 706 ldhx #_cmdtab ;point to the command table 80BC [05] CD8A19 707 jsr _get_atbl ;get the routine corresponding to the menu entry 80BF [03] 2403 708 bcc um2 ;menu item not recognized, print error and try again 80C1 [04] FD 709 jsr ,x ;call the selected menu routine 80C2 [03] 20E3 710 bra um1 ;go get another command 711 80C4 [03] 458135 712 um2: ldhx #Err_Msg ;"What?" 80C7 [05] CD8A13 713 jsr _puts 80CA [03] 20DB 714 bra um1 715 Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 19 80CC 0D0A0D0A 716 ExerciserBanner: fcb CR,LF,CR,LF,'~~ Digital Breadboard Exerciser v1.0 G. Heron N2APB ~~',CR,LF,0 7E7E2044 69676974 616C2042 72656164 626F6172 64204578 65726369 73657220 76312E30 2020472E 20486572 6F6E204E 32415042 207E7E0D 0A00 810A 0D0A0D0A 717 Prompt: fcb CR,LF,CR,LF,'Excerciser (D,S,L,V,Y,E,W,R,T,A,X,H) >',0 45786365 72636973 65722028 442C532C 4C2C562C 592C452C 572C522C 542C412C 582C4829 203E00 8135 0D0A5768 718 Err_Msg: fcb CR,LF,'What?',0 61743F00 813D 45786572 719 ExerciserMsg: fcb 'Exerciser v1.0',0 63697365 72207631 2E3000 720 721 ;*************************************************** ***************** 722 ;**************** COMMAND LOOKUP TABLE ***************** 723 ;*************************************************** ***************** 724 _cmdtab: 814C 44 725 fcb 'D' 814D 816E 726 fdb DDS 814F 53 727 fcb 'S' 8150 81A2 728 fdb Shaft_Encoder 8152 4C 729 fcb 'L' 8153 8267 730 fdb LED_Port_Test 8155 59 731 fcb 'Y' 8156 8454 732 fdb Display_Test 8158 45 733 fcb 'E' 8159 83CE 734 fdb Erase_EEPROM 815B 57 735 fcb 'W' 815C 8401 736 fdb Write_EEPROM 815E 52 737 fcb 'R' 815F 838D 738 fdb Read_EEPROM Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 20 8161 54 739 fcb 'T' 8162 835D 740 fdb Timing_Test 8164 41 741 fcb 'A' 8165 84AD 742 fdb ADC_Test 8167 48 743 fcb 'H' 8168 8520 744 fdb Help 816A 58 745 fcb 'X' 816B 851E 746 fdb Monitor 816D 00 747 fcb NUL 748 Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 21 816E 749 $page 750 ;*************************************************** ***************** 751 ;***************** COMMAND PROCESSORS ***************** 752 ;*************************************************** ***************** 753 754 ;------------------------ 755 ; DDS -- Command 'D' 756 ;------------------------ 757 DDS: 816E [03] 458187 758 ldhx #Freq_Msg ;"DDS Freq set to 10 MHz" 8171 [05] CD8A13 759 jsr _puts ;put string to serial terminal 8174 [04] 6E016C 760 mov #$01,DDS_w4 ;test DDS programming data 8177 [04] 6EEE6D 761 mov #$EE,DDS_w3 817A [04] 6E096E 762 mov #$09,DDS_w2 817D [04] 6E006F 763 mov #$00,DDS_w1 8180 [04] 6E0070 764 mov #$00,DDS_w0 8183 [05] CD8715 765 jsr set_dds ;set the DDS 8186 [04] 81 766 rts 767 768 Freq_Msg: 8187 0D0A2020 769 fcb CR,LF,' DDS Freq set to 10 MHz',0 44445320 46726571 20736574 20746F20 3130204D 487A00 770 771 ;------------------------------ 772 ; Shaft Encoder -- Command 'S' 773 ;------------------------------ 774 Shaft_Encoder: 81A2 [03] 4581D5 775 ldhx #Enc_Msg ;"Shaft Encoder (Special)" 81A5 [05] CD8A13 776 jsr _puts ;put string to serial terminal 81A8 [05] CD8881 777 jsr LCD_Clear 81AB [05] CD867D 778 jsr Wait64ms 81AE [05] CD88B0 779 jsr ClearLCDLine2 81B1 [05] CD867D 780 jsr Wait64ms 81B4 [02] A6C0 781 lda #$C0 ;point to 2nd line on LCD 81B6 [05] CD87A7 782 jsr Cmnd2LCD 81B9 [03] 458203 783 ldhx #EncoderMsg 81BC [05] CD88E2 784 jsr Disp_Msg 81BF [04] 6E3059 785 mov #$30,enc_tens ;init the turns counter 81C2 [04] 6E305A 786 mov #$30,enc_units 81C5 [05] CD873D 787 se1: jsr Do_Special_Encoder ;process the encoder turns 81C8 [03] 2605 788 bne se2 Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 22 81CA [05] CD8210 789 jsr decrease_digit_display ;CCW turn detected 81CD [03] 20F6 790 bra se1 81CF [05] CD8231 791 se2: jsr increase_digit_display ;CW turn detected 81D2 [03] 20F1 792 bra se1 81D4 [04] 81 793 rts 794 795 Enc_Msg: 81D5 0D0A2020 796 fcb CR,LF,' Shaft Encoder (Special) - to exit',0 53686166 7420456E 636F6465 72202853 70656369 616C2920 2D203C72 65736574 3E20746F 20657869 7400 797 EncoderMsg: 8203 456E636F 798 fcb 'Encoder = 00',0 64657220 3D203030 00 799 800 ;----------------------- 801 ;encoder turned down (ccw) 802 803 Decrease_Digit_Display: 8210 [04] 3A5A 804 dec enc_units ;decrement units digit 8212 [02] A62F 805 lda #$2F ;units at min? 8214 [03] B15A 806 cmp enc_units 8216 [03] 2702 807 beq dwn1a ;yes, roll down 8218 [03] 2013 808 bra dwn1b ;no,just continue 809 821A [04] 6E395A 810 dwn1a: mov #$39,enc_units ;roll down units to 9 821D [04] 3A59 811 dec enc_tens ;and decr tens 821F [02] A62F 812 lda #$2F 8221 [03] B159 813 cmp enc_tens ;tens at min? 8223 [03] 2702 814 beq dwn1c ;yes, reset cntr to 00 8225 [03] 2006 815 bra dwn1b ;no, just continue 816 8227 [02] A639 817 dwn1c: lda #$39 8229 [03] B75A 818 sta enc_units ;reset tens to zero 822B [03] B759 819 sta enc_tens ; and units to zero 820 822D [05] CD8252 821 dwn1b: jsr update_digits ;update Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 23 counter digits 8230 [04] 81 822 rts 823 824 ;----------------------------------- 825 ;encoder turned up (cw) 826 827 Increase_Digit_Display: 8231 [04] 3C5A 828 inc enc_units ;increment units digit 8233 [02] A63A 829 lda #$3A ;units at max? 8235 [03] B15A 830 cmp enc_units 8237 [03] 2702 831 beq up1a ;yes, roll over 8239 [03] 2013 832 bra up1b ;no, just continue 833 823B [04] 6E305A 834 up1a: mov #$30,enc_units ;roll over units to zero 823E [04] 3C59 835 inc enc_tens ;and bump tens 8240 [02] A63A 836 lda #$3A ;tens at max? 8242 [03] B159 837 cmp enc_tens 8244 [03] 2702 838 beq up1c ;yes, reset cntr to 00 8246 [03] 2006 839 bra up1b ;no, just continue 840 8248 [02] A630 841 up1c: lda #$30 824A [03] B75A 842 sta enc_units ;reset tens to zero 824C [03] B759 843 sta enc_tens ; and units to zero 844 824E [05] CD8252 845 up1b: jsr update_digits ;update counter digits 8251 [04] 81 846 rts 847 848 ;------------- 849 update_digits: 8252 [02] A6CA 850 lda #$CA ;point to tens digit on 2nd line 8254 [05] CD87A7 851 jsr Cmnd2LCD 8257 [03] B659 852 lda enc_tens ;send the tens digit there 8259 [05] CD87B9 853 jsr Data2LCD 825C [02] A6CB 854 lda #$CB ;point to units digit on 2nd line 825E [05] CD87A7 855 jsr Cmnd2LCD 8261 [03] B65A 856 lda enc_units ;send the units digit there 8263 [05] CD87B9 857 jsr Data2LCD 8266 [04] 81 858 rts 859 860 ;------------------------------ 861 ; LED Port Test -- Command 'L' 862 ;------------------------------ 863 LED_Port_Test: 8267 [03] 45834B 864 ldhx #LED_Msg ;"LED Port Test" Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 24 826A [05] CD8A13 865 jsr _puts ;put string to serial terminal 866 826D [04] 1B02 867 bclr 5,portc 826F [05] CD8347 868 jsr Wait_LED 8272 [04] 1A02 869 bset 5,portc 8274 [04] 1902 870 bclr 4,portc 8276 [05] CD8347 871 jsr Wait_LED 8279 [04] 1802 872 bset 4,portc 827B [04] 1502 873 bclr 2,portc 827D [05] CD8347 874 jsr Wait_LED 8280 [04] 1402 875 bset 2,portc 8282 [04] 1509 876 bclr 2,portf 8284 [05] CD8347 877 jsr Wait_LED 8287 [04] 1409 878 bset 2,portf 8289 [04] 1309 879 bclr 1,portf 828B [05] CD8347 880 jsr Wait_LED 828E [04] 1209 881 bset 1,portf 8290 [04] 1109 882 bclr 0,portf 8292 [05] CD8347 883 jsr Wait_LED 8295 [04] 1009 884 bset 0,portf 8297 [04] 130A 885 bclr 1,portg 8299 [05] CD8347 886 jsr Wait_LED 829C [04] 120A 887 bset 1,portg 829E [04] 110A 888 bclr 0,portg 82A0 [05] CD8347 889 jsr Wait_LED 82A3 [04] 100A 890 bset 0,portg 82A5 [04] 1F08 891 bclr 7,porte 82A7 [05] CD8347 892 jsr Wait_LED 82AA [04] 1E08 893 bset 7,porte 82AC [04] 1D08 894 bclr 6,porte 82AE [05] CD8347 895 jsr Wait_LED 82B1 [04] 1C08 896 bset 6,porte 82B3 [04] 1303 897 bclr 1,portd 82B5 [05] CD8347 898 jsr Wait_LED 82B8 [04] 1203 899 bset 1,portd 82BA [04] 150A 900 bclr 2,portg 82BC [05] CD8347 901 jsr Wait_LED 82BF [04] 140A 902 bset 2,portg 82C1 [04] 1301 903 bclr 1,portb 82C3 [05] CD8347 904 jsr Wait_LED 82C6 [04] 1201 905 bset 1,portb 82C8 [04] 1701 906 bclr 3,portb 82CA [05] CD8347 907 jsr Wait_LED 82CD [04] 1601 908 bset 3,portb 82CF [04] 1B01 909 bclr 5,portb 82D1 [05] CD8347 910 jsr Wait_LED 82D4 [04] 1A01 911 bset 5,portb 82D6 [04] 1F01 912 bclr 7,portb 82D8 [05] CD8347 913 jsr Wait_LED 82DB [04] 1E01 914 bset 7,portb 82DD [04] 1501 915 bclr 2,portb 82DF [05] CD8347 916 jsr Wait_LED 82E2 [04] 1401 917 bset 2,portb 82E4 [04] 1901 918 bclr 4,portb 82E6 [05] CD8347 919 jsr Wait_LED 82E9 [04] 1801 920 bset 4,portb 82EB [04] 1D01 921 bclr 6,portb Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 25 82ED [05] CD8347 922 jsr Wait_LED 82F0 [04] 1C01 923 bset 6,portb 82F2 [04] 1103 924 bclr 0,portd 82F4 [05] CD8347 925 jsr Wait_LED 82F7 [04] 1003 926 bset 0,portd 82F9 [04] 1703 927 bclr 3,portd 82FB [05] CD8347 928 jsr Wait_LED 82FE [04] 1603 929 bset 3,portd 8300 [04] 1503 930 bclr 2,portd 8302 [05] CD8347 931 jsr Wait_LED 8305 [04] 1403 932 bset 2,portd 8307 [04] 110B 933 bclr 0,porth 8309 [05] CD8347 934 jsr Wait_LED 830C [04] 100B 935 bset 0,porth 830E [04] 1903 936 bclr 4,portd 8310 [05] CD8347 937 jsr Wait_LED 8313 [04] 1803 938 bset 4,portd 8315 [04] 1D03 939 bclr 6,portd 8317 [05] CD8347 940 jsr Wait_LED 831A [04] 1C03 941 bset 6,portd 831C [04] 130B 942 bclr 1,porth 831E [05] CD8347 943 jsr Wait_LED 8321 [04] 120B 944 bset 1,porth 8323 [04] 1B03 945 bclr 5,portd 8325 [05] CD8347 946 jsr Wait_LED 8328 [04] 1A03 947 bset 5,portd 832A [04] 1F03 948 bclr 7,portd 832C [05] CD8347 949 jsr Wait_LED 832F [04] 1E03 950 bset 7,portd 8331 [04] 1708 951 bclr 3,porte 8333 [05] CD8347 952 jsr Wait_LED 8336 [04] 1608 953 bset 3,porte 8338 [04] 1908 954 bclr 4,porte 833A [05] CD8347 955 jsr Wait_LED 833D [04] 1808 956 bset 4,porte 833F [04] 1B08 957 bclr 5,porte 8341 [05] CD8347 958 jsr Wait_LED 8344 [04] 1A08 959 bset 5,porte 8346 [04] 81 960 rts 961 962 Wait_LED: 8347 [05] CD867D 963 jsr Wait64ms 834A [04] 81 964 rts 965 966 LED_Msg: 834B 0D0A2020 967 fcb CR,LF,' LED Port Test',0 4C454420 506F7274 20546573 7400 968 969 ;------------------------------ 970 ; Timing Test -- Command 'T' 971 ;------------------------------ 972 Timing_Test: 835D [03] 45836C 973 ldhx #Timing_Msg ;"Timing Test (reset to exit)" 8360 [05] CD8A13 974 jsr _puts ;put string Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 26 to serial terminal 8363 [02] 9B 975 sei 8364 [04] 1C09 976 tt1: bset HeartbeatLED,portF 977 ; jsr Wait100us ;change this Wait to reflect desired test 8366 [04] 1D09 978 bclr HeartbeatLED,portF ;else, without the waits, it's a cycle timing test 979 ; jsr Wait100us ;change this Wait to reflect desired test 8368 [03] 20FA 980 bra tt1 836A [02] 9A 981 cli 836B [04] 81 982 rts 983 984 Timing_Msg: 836C 0D0A2020 985 fcb CR,LF,' Cycle Timing (reset to exit)',0 4379636C 65205469 6D696E67 20287265 73657420 746F2065 78697429 00 986 987 ;------------------------------ 988 ; Read EEPROM -- Command 'R' 989 ;------------------------------ 990 Read_EEPROM: 838D [03] 4583AF 991 ldhx #Read_Msg ;"EEPROM = " 8390 [05] CD8A13 992 jsr _puts ;put string to serial terminal 8393 [03] 450800 993 ldhx #$800 ;EEPROM mem is 800-9FF 8396 [04] 6E2078 994 mov #32,EEline_count ;32 lines of EEPROM to display 8399 [04] 6E1077 995 ree1: mov #16,EEbyte_count ;display 16 bytes/line 839C [02] F6 996 ree2: lda ,x ;get the EEPROM byte 839D [05] CD8A01 997 jsr _pbyte ;else print the char to the terminal 83A0 [05] CD89EC 998 jsr _space 83A3 [02] AF01 999 aix #1 83A5 [05] 3B77F4 1000 dbnz EEbyte_count,ree2 ;not done with current line of 16 yet 83A8 [05] CD89E6 1001 jsr _crlf 83AB [05] 3B78EB 1002 dbnz EEline_count,ree1 ;not do with all 32 lines of EEPROM yet 83AE [04] 81 1003 rts 1004 1005 Read_Msg: 83AF 0D0A2020 1006 fcb CR,LF,' EEPROM Memory (800-9FF):',C R,LF,0 45455052 4F4D204D 656D6F72 79202838 Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 27 30302D39 4646293A 0D0A00 1007 1008 ;------------------------------ 1009 ; Erase EEPROM -- Command 'E' 1010 ;------------------------------ 1011 Erase_EEPROM: 83CE [05] CD8921 1012 jsr Erase_EEPROM_All ;clear all 512 locations 83D1 [03] 4583D8 1013 ldhx #Erase_Msg ;"EEPROM addresses 800-9FF now erased!" 83D4 [05] CD8A13 1014 jsr _puts ;put string to serial terminal 83D7 [04] 81 1015 rts 1016 1017 Erase_Msg: 83D8 0D0A2020 1018 fcb CR,LF,' EEPROM addresses 800-9FF now erased!',0 45455052 4F4D2061 64647265 73736573 20383030 2D394646 206E6F77 20657261 73656421 00 1019 1020 ;------------------------------ 1021 ; Write EEPROM -- Command 'W' 1022 ;------------------------------ 1023 Write_EEPROM: 8401 [03] 45842E 1024 ldhx #Write_Msg ;"Enter EEPROM data to be written: " 8404 [05] CD8A13 1025 jsr _puts ;put string to serial terminal 8407 [05] CD89CB 1026 jsr _gets ;get an input string 840A [03] 2521 1027 bcs we_exit ;if ctl+C or ESC, exit 840C [04] C6040A 1028 lda _inbuf ;get the character 840F [03] 271C 1029 beq we_exit ;nothing entered (just ENTER), exit 1030 1031 ;transfer from input buffer to EEPROM 1032 8411 [03] 450800 1033 ldhx #$800 ;start of EEPROM = 800 8414 [04] 3573 1034 sthx to_addr 8416 [03] 45040A 1035 ldhx #_inbuf ;point to start of input buffer 8419 [04] 3575 1036 sthx from_addr 841B [04] 5575 1037 we1: ldhx from_addr 841D [02] F6 1038 lda ,x ;get char from input buffer Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 28 841E [03] 270D 1039 beq we_exit ;exit if EOT terminator found (0) 8420 [01] 5C 1040 incx 8421 [04] 3575 1041 sthx from_addr 8423 [04] 5573 1042 ldhx to_addr 8425 [05] CD88EC 1043 jsr Write_EEPROM_byte ;write reg A to loc (hx) in EEPROM area 8428 [01] 5C 1044 incx 8429 [04] 3573 1045 sthx to_addr 842B [03] 20EE 1046 bra we1 1047 1048 we_exit: 842D [04] 81 1049 rts 1050 1051 Write_Msg: 842E 0D0A2020 1052 fcb CR,LF,' Enter EEPROM data to be written: ',0 456E7465 72204545 50524F4D 20646174 6120746F 20626520 77726974 74656E3A 2000 1053 1054 ;------------------------------ 1055 ; Display Test -- Command 'Y' 1056 ;------------------------------ 1057 Display_Test: 8454 [05] CD88B0 1058 jsr ClearLCDline2 8457 [03] 45847A 1059 ldhx #DispTst_Msg ;"LCD Display Test" 845A [05] CD8A13 1060 jsr _puts ;put string to serial terminal 845D [05] CD8881 1061 jsr LCD_clear ;clear the LCD 8460 [05] CD867D 1062 jsr Wait64ms 8463 [02] A680 1063 lda #$80 ;point to first char, line 1 8465 [05] CD87A7 1064 jsr Cmnd2LCD 8468 [03] 45848B 1065 ldhx #Line1Msg 846B [05] CD88E2 1066 jsr Disp_Msg ;display line 1 test message 846E [02] A6C0 1067 lda #$C0 ;point to first char, line 2 8470 [05] CD87A7 1068 jsr Cmnd2LCD 8473 [03] 45849C 1069 ldhx #Line2Msg 8476 [05] CD88E2 1070 jsr Disp_Msg 8479 [04] 81 1071 rts 1072 1073 DispTst_Msg: 847A 0D0A2020 1074 fcb CR,LF,' Display Test',0 44697370 6C617920 54657374 00 Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 29 1075 Line1Msg: 848B 41424344 1076 fcb 'ABCDefghIJKLmnop',0 65666768 494A4B4C 6D6E6F70 00 1077 Line2Msg: 849C 51525354 1078 fcb 'QRSTuv0123456789',0 75763031 32333435 36373839 00 1079 1080 ;-------------------------------------- 1081 ; Analog-to-Digital Test -- Command 'A' 1082 ;-------------------------------------- 1083 ADC_Test: 84AD [03] 4584F7 1084 ldhx #ADC_Msg ;"Analog-To-Di gital (ADC) Test" 84B0 [05] CD8A13 1085 jsr _puts ;put string to serial terminal 84B3 [03] 458517 1086 ldhx #ADC_Msg_LCD 84B6 [02] A6C0 1087 lda #$C0 ;point to 1st char line 2 84B8 [05] CD87A7 1088 jsr Cmnd2LCD 84BB [05] CD88E2 1089 jsr Disp_Msg ;put string to LCD 84BE [04] 6E703A 1090 mov #$70,ADCLK ;select clock divide of 011 1091 ; and set the ADICLK bit 1092 adc_start: 84C1 [04] 6E0038 1093 mov #$00,ADSCR ;clear COCO, AIEN, ADCO 1094 ; and specify port 0, and start a conversion 1095 adc_wait: 84C4 [05] 0F38FD 1096 brclr 7,ADSCR,adc_wait ;wait for Conversion Complete (COCO) 84C7 [03] B639 1097 lda ADR ;read the A/D register 84C9 [02] 87 1098 psha 84CA [03] B066 1099 sub a2d_last ;compare to last reading 84CC [02] 86 1100 pula 84CD [03] 27F2 1101 beq adc_start ;go back and read again if same 84CF [03] B766 1102 sta a2d_last ;else save new value 84D1 [05] CD8A01 1103 jsr _pbyte ;and output it 84D4 [05] CD89E6 1104 jsr _crlf 84D7 [02] A6C6 1105 lda #$C6 ;point to digit position on 2nd line 84D9 [05] CD87A7 1106 jsr Cmnd2LCD 84DC [03] B666 1107 lda a2d_last ;get the A/D data value back again 84DE [03] 62 1108 nsa ;swap upper/lower nibbles Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 30 84DF [05] CD89D7 1109 jsr _nib_to_asc ;convert the upper nibble to ascii 84E2 [05] CD87B9 1110 jsr data2LCD ;and display it 84E5 [02] A6C7 1111 lda #$C7 ;point to digit position on 2nd line 84E7 [05] CD87A7 1112 jsr Cmnd2LCD 84EA [03] B666 1113 lda a2d_last ;get the A/D data value back again 84EC [05] CD89D7 1114 jsr _nib_to_asc ;convert the lower nibble to ascii 84EF [05] CD87B9 1115 jsr data2LCD ;and display it 84F2 [05] CD867D 1116 jsr Wait64ms 84F5 [03] 20CA 1117 bra adc_start ;go trigger another conversion 1118 1119 ADC_Msg: 84F7 0D0A2020 1120 fcb CR,LF,' Analog-To-Digital Converter ',0 416E616C 6F672D54 6F2D4469 67697461 6C20436F 6E766572 74657200 1121 1122 ADC_Msg_LCD: 8517 412F4420 1123 fcb 'A/D = ',0 3D2000 1124 1125 ;------------------------------ 1126 ; Exit to Monitor -- Command 'X' 1127 ;------------------------------ 1128 Monitor: 851E [09] 83 1129 swi ; Software Interrupt enters HCmon 851F [04] 81 1130 rts 1131 1132 ;------------------------------------------- 1133 ; Help -- Command 'H' 1134 ;------------------------------------------- 1135 Help: 8520 [03] 458527 1136 ldhx #Help_Msg ;"Help Menu" 8523 [05] CD8A13 1137 jsr _puts ;put string to serial terminal 8526 [04] 81 1138 rts 1139 1140 Help_Msg: 8527 0D0A 1141 fcb CR,LF 8529 48656C70 1142 fcb 'Help Menu ',CR,LF 204D656E 75202020 20202020 200D0A 853C 3D3D3D3D 1143 fcb '========= ',CR,LF 3D3D3D3D Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 31 3D202020 20202020 200D0A 854F 2044203D 1144 fcb ' D = DDS Set ',CR,LF 20444453 20536574 20202020 200D0A 8562 2053203D 1145 fcb ' S = Shaft Enc ',CR,LF 20536861 66742045 6E632020 200D0A 8575 204C203D 1146 fcb ' L = LED Ports ',CR,LF 204C4544 20506F72 74732020 200D0A 8588 2059203D 1147 fcb ' Y = Display Test',CR,LF 20446973 706C6179 20546573 740D0A 859B 2045203D 1148 fcb ' E = Erase EEPROM',CR,LF 20457261 73652045 4550524F 4D0D0A 85AE 2057203D 1149 fcb ' W = Write EEPROM',CR,LF 20577269 74652045 4550524F 4D0D0A 85C1 2052203D 1150 fcb ' R = Read EEPROM ',CR,LF 20526561 64204545 50524F4D 200D0A 85D4 2054203D 1151 fcb ' T = Timing Test ',CR,LF 2054696D 696E6720 54657374 200D0A 85E7 2041203D 1152 fcb ' A = ADC Test ',CR,LF 20414443 20546573 74202020 200D0A 85FA 2058203D 1153 fcb ' X = Exit to HCmon',CR,LF 20457869 7420746F 2048436D 6F6E0D0A 860E 2048203D 1154 fcb ' H = Help ',CR,LF 2048656C 70202020 20202020 200D0A Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 32 8621 00 1155 fcb 0 1156 1157 ;*************************************************** *********************** 1158 ;*************** HCmon_LCD_disp ******************************* 1159 ;* Routine called from HCmon to display message to LCD * 1160 ;*************************************************** *********************** 1161 1162 HCmon_LCD_disp: 8622 [05] CD8826 1163 jsr LCD_init 8625 [05] CD8881 1164 jsr LCD_clear 8628 [03] 45863A 1165 ldhx #mon_msg1 862B [05] CD88E2 1166 jsr disp_msg 862E [02] A6C0 1167 lda #$C0 8630 [05] CD87A7 1168 jsr cmnd2lcd 8633 [03] 458649 1169 ldhx #mon_msg2 8636 [05] CD88E2 1170 jsr disp_msg 8639 [04] 81 1171 rts 1172 1173 mon_msg1: 863A 48436D6F 1174 fcb 'HCmonitor v1.0',0 6E69746F 72207631 2E3000 1175 1176 mon_msg2: 8649 472E4865 1177 fcb 'G.Heron N2APB',0 726F6E20 4E324150 4200 1178 1179 Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 33 8657 1180 $page 1181 ;*************************************************** *********************** 1182 ;***************** DELAY ROUTINES ******************************* 1183 ;*************************************************** *********************** 1184 1185 ;--------------------------------------------------- ----------------------- 1186 ; Delay -- This subroutine performs a simple software delay loop based upon 1187 ; the value passed in ACC. The following timing calculation applies: 1188 ; delay = ((ACC * 74) + 12) (tcyc) 1189 1190 delay: 8657 [02] 87 1191 psha ;[2] save delay parameter temporarily 1192 delay1: 8658 [02] A616 1193 lda #22T ;[2] initialize 5us loop counter 1194 ; (repeat for timing) 1195 delay2: 865A [03] 4BFE 1196 dbnza delay2 ;[3] decrement inner delay loop counter 865C [06] 9E6B01F8 1197 dbnz 1,sp,delay1 ;[6] decrement outer delay loop counter 8660 [02] 86 1198 pula ;[2] deallocate local variable 8661 [04] 81 1199 rts ;[4] return 1200 1201 ;--------------------------------------------------- ----------------------- 1202 ; Wait500ms -- Waits here for (10 x 50 x 1ms) = 500ms 1203 1204 wait500ms: 8662 [02] A60A 1205 lda #10 8664 [03] B772 1206 sta count_hi 8666 [02] A650 1207 w500m1: lda #$50 8668 [03] B771 1208 sta count_lo 866A [05] CD86A9 1209 w500m2: jsr wait1ms 866D [05] 3B71FA 1210 dbnz count_lo,w500m2 8670 [05] 3B72F3 1211 dbnz count_hi,w500m1 8673 [04] 81 1212 rts 1213 1214 ;--------------------------------------------------- ----------------------- 1215 ; Wait100ms-- Waits here for 100ms 1216 1217 wait100ms: 8674 [02] A664 1218 lda #100 8676 [02] 87 1219 w100a: psha 8677 [04] AD30 1220 bsr wait1ms 8679 [02] 86 1221 pula Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 34 867A [03] 4BFA 1222 dbnza w100a 867C [04] 81 1223 rts 1224 1225 ;--------------------------------------------------- ----------------------- 1226 ; Wait64ms-- Waits here for 64ms 1227 1228 wait64ms: 867D [02] A640 1229 lda #64 867F [02] 87 1230 w64a: psha 8680 [04] AD27 1231 bsr wait1ms 8682 [02] 86 1232 pula 8683 [03] 4BFA 1233 dbnza w64a 8685 [04] 81 1234 rts 1235 1236 ;--------------------------------------------------- ----------------------- 1237 ; Wait50ms-- Waits here for 50ms 1238 1239 wait50ms: 8686 [04] 6E1055 1240 mov #16,timeout1 8689 [03] 3D55 1241 w50a: tst timeout1 868B [03] 26FC 1242 bne w50a 868D [04] 81 1243 rts 1244 1245 ;--------------------------------------------------- ----------------------- 1246 ; Wait32ms-- Waits here for 32ms 1247 1248 wait32ms: 868E [02] A620 1249 lda #32 8690 [02] 87 1250 w32a: psha 8691 [04] AD16 1251 bsr wait1ms 8693 [02] 86 1252 pula 8694 [03] 4BFA 1253 dbnza w32a 8696 [04] 81 1254 rts 1255 1256 ;--------------------------------------------------- ----------------------- 1257 ; Wait64ms-- Waits here for 16ms 1258 1259 wait16ms: 8697 [02] A610 1260 lda #16 8699 [02] 87 1261 w16a: psha 869A [04] AD0D 1262 bsr wait1ms 869C [02] 86 1263 pula 869D [03] 4BFA 1264 dbnza w16a 869F [04] 81 1265 rts 1266 1267 ;--------------------------------------------------- ----------------------- 1268 ; Wait10ms-- Waits here for 10ms 1269 1270 Wait10ms: 86A0 [02] A60A 1271 lda #10 86A2 [02] 87 1272 w10a: psha 86A3 [04] AD04 1273 bsr wait1ms 86A5 [02] 86 1274 pula Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 35 86A6 [03] 4BFA 1275 dbnza w10a 86A8 [04] 81 1276 rts 1277 1278 ;--------------------------------------------------- ----------------------- 1279 ; Wait1ms-- Waits here for 1ms 1280 1281 wait1ms: 86A9 [02] A60A 1282 lda #10 86AB [02] 87 1283 w1msa: psha 86AC [04] AD04 1284 bsr wait100us 86AE [02] 86 1285 pula 86AF [03] 4BFA 1286 dbnza w1msa 86B1 [04] 81 1287 rts 1288 1289 ;--------------------------------------------------- ----------------------- 1290 ; Wait100us -- Waits here for 100us 1291 ; 1 cycle = .11454545 US 1292 ; (137 x (5 x .11454545)) + (6 x .11454545) 1293 ; (174 x .5727) + .687 = 100 us 1294 1295 wait100us: 86B2 [02] A6AE 1296 lda #174 ; [2] 86B4 [01] 4A 1297 w100u: deca ; [1] 86B5 [01] 9D 1298 nop ; [1] 86B6 [03] 26FC 1299 bne w100u ; [3] 86B8 [04] 81 1300 rts ; [4] 1301 1302 ;--------------------------------------------------- ----------------------- 1303 ; Wait1us -- Waits here for 1us 1304 1305 wait1us: 86B9 [03] B603 1306 lda us1 86BB [03] 4BFE 1307 dbnza * 86BD [04] 81 1308 rts 1309 1310 ;*************************************************** ********** 1311 ;***************** TIMER MODULE ************* ********** 1312 ;*************************************************** ********** 1313 1314 ;--------------------------------------------------- ---------- 1315 ; Init_Timer - Turns on timer A channel 1 for an Output 1316 ; Compare in approximately 2ms. Creates an interrupt 1317 ; vector to the Timer ISR (T_ISR), where Timeout1, 1318 ; Timeout2 and Timeout3 are decremeted. If a timer 1319 ; reaches 0, then a user-specified operation is Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 36 1320 ; done. Thus, the user can either set a timer in his 1321 ; code and sit there waiting on it to become 0, or 1322 ; he may place the timeout action routine right here 1323 ; in the Timer Handlers. We use the latter technique 1324 ; for the "heartbeat" LED blink. We set Timeout1 to 1325 ; FF in the Timer1 Handler below, and when 255 ticks 1326 ; of the 2ms timer interrupt occur, we toggle the state 1327 ; of the heartbeat LED and reset Timeout1 to occur again 1328 ; in another 255 ticks. 1329 1330 1331 Init_Timer: 86BE [04] 6E3620 1332 mov #$36,TASC ; Timer A - Cleared + Stopped. 1333 ; Clicks once every 64 BUS Cycles 1334 ; 77t Clicks ~ 2ms 1335 86C1 [04] 6E002A 1336 mov #$0,TACH1H ; Set Output Compare to happen 77T clicks 86C4 [04] 6E4D2B 1337 mov #77T,TACH1L ; after we start the timer. (~2ms). The 1338 ; timer interrupt will set OC for another ~2ms. 1339 86C7 [04] 6E5429 1340 mov #$54,TASC1 ; Timer A Channel 1 1341 ; Set for Output Compare operation. 1342 86CA [04] 6E0620 1343 mov #$06,TASC ; Start the timer 86CD [04] 81 1344 rts 1345 1346 1347 **************************************************** ********** 1348 * T_ISR - Timer Interrupt Service Routine. * 1349 * after a RESET. * 1350 **************************************************** ********** 1351 T_ISR: 86CE [02] 8B 1352 pshh 86CF [02] 89 1353 pshx 86D0 [02] 87 1354 psha 86D1 [03] B629 1355 lda tasc1 86D3 [02] A47F 1356 and #$7f 86D5 [03] B729 1357 sta tasc1 ; Clear O.C. Flag 86D7 [04] 552A 1358 ldhx tach1h 86D9 [02] AF4D 1359 aix #77T ; Setup another Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 37 interrupt in ~2ms 86DB [04] 352A 1360 sthx tach1h 1361 1362 Check_t1: 86DD [03] 3D55 1363 tst timeout1 86DF [03] 2707 1364 beq check_t2 ; Is Timeout 1 currently active? 86E1 [04] 3A55 1365 dec timeout1 ; yes 86E3 [03] 2603 1366 bne check_t2 ; Did it just finish counting down? 86E5 [05] CD8702 1367 jsr t1_handler ; Yes - Execute Timeout 1 handler 1368 1369 Check_t2: 86E8 [03] 3D56 1370 tst timeout2 86EA [03] 2707 1371 beq check_t3 ; Is Timeout 2 currently active? 86EC [04] 3A56 1372 dec timeout2 ; yes 86EE [03] 2603 1373 bne check_t3 ; Did it just finish counting down? 86F0 [05] CD870F 1374 jsr t2_handler ; Yes - Execute Timeout 2 handler 1375 1376 Check_t3: 86F3 [03] 3D57 1377 tst timeout3 86F5 [03] 2707 1378 beq done_tisr ; Is Timeout 3 currently active? 86F7 [04] 3A57 1379 dec timeout3 ; yes 86F9 [03] 2603 1380 bne done_tisr ; Did it just finish counting down? 86FB [05] CD8711 1381 jsr t3_handler ; Yes - Execute Timeout 3 handler 1382 1383 done_tisr: 86FE [02] 86 1384 pula 86FF [02] 88 1385 pulx 8700 [02] 8A 1386 pulh 8701 [07] 80 1387 rti 1388 1389 **************************************************** ************ 1390 * Timeout Handlers - All the user has to do is set one of the * 1391 * timeout variables to any number n (1-255) * 1392 * and the timeout handler will be executed * 1393 * in 2*n milliseconds. Setting the timeout * 1394 * variable from within the handler will * 1395 * cause a periodic timeout as shown in * 1396 * timeout 1. * 1397 **************************************************** ************ 1398 t1_handler: Exerciser_v1.asm Assembled with CASM08Z 4/19/2003 10:46:27 PM PAGE 38 8702 [02] A6FF 1399 lda #255 8704 [03] B755 1400 sta timeout1 8706 [05] 0D0903 1401 brclr 6,portF,t1a ;toggle heartbeat LED 8709 [04] 1D09 1402 bclr 6,portF 870B [04] 81 1403 rts 870C [04] 1C09 1404 t1a: