2870 lines
175 KiB
Plaintext
2870 lines
175 KiB
Plaintext
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 1
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00001 ; CMETERA.ASM
|
||
00002 ; Fr. Tom McGahee's PIC CAPACITANCE METER
|
||
00003 ;
|
||
00004 ; Fr. Thomas McGahee
|
||
00005 ; Don Bosco Technical High School
|
||
00006 ; 202 Union Ave
|
||
00007 ; Paterson, NJ 07502 USA
|
||
00008 ;
|
||
00009 ; tom_mcgahee@sigmais.com
|
||
00010 ; (973)595-6655
|
||
00011 ;
|
||
00012 ; permission granted for individual use
|
||
00013 ;
|
||
00014 ; Microchip MPASM format
|
||
00015 ; Specifically designed for PIC16C84. Skeleton file.
|
||
00016 ;
|
||
00017
|
||
00018 ; note: set assembler to case-insensitive, except within strings using /c- option
|
||
00019 ;
|
||
00020
|
||
00021 ;OPERATIONAL DESCRIPTION OF PROJECT
|
||
00022
|
||
00023
|
||
00024 ;the mclear (reset) switch causes a reset and return to autorange.
|
||
00025 ;the other three switches cause an immediate move to manual mode.
|
||
00026 ;zeroswitch causes most recent displayed reading to be used as
|
||
00027 ;a zero offset. this allows the user to compare two capacitors.
|
||
00028 ;a + or - sign is displayed to indicate relative value.
|
||
00029 ;hold key down until updating stops. upon release the
|
||
00030 ;current value will be displayed.
|
||
00031
|
||
00032 ;first line of lcd displays a + or a blinking - sign in the first
|
||
00033 ;position. This indicates whether the current displayed value is
|
||
00034 ;higher or lower than the Comparison Value (normally 0). You may
|
||
00035 ;"zero-out" any value desired by pressing the ZERO button. This will
|
||
00036 ;cause the current value to be subtracted from all future readings.
|
||
00037 ;pressing the ZERO button also forces the unit into Manual Mode.
|
||
00038 ;you can return to Auto Mode by removing the capacitor and pressing
|
||
00039 ;the reset button, or by removing the capacitor and turning the
|
||
00040 ;power off and then on again.
|
||
00041
|
||
00042 ;manual mode can also be entered by pressing either the UP or DOWN
|
||
00043 ;buttons. (hold button down until updating stops, then release).
|
||
00044 ;UP and DOWN are used to move from one range to another in Manual Mode.
|
||
00045 ;unit starts out in Auto Mode, and will automatically switch to the
|
||
00046 ;best (most accurate) range for any given capacitor. Auto Mode has
|
||
00047 ;built-in hysteresis to prevent the capmeter from constantly
|
||
00048 ;cycling between ranges.
|
||
00049
|
||
00050 ;the second position on the first line is sometimes occupied by a
|
||
00051 ;blinking letter "M". This indicates that you are in Manual Mode,
|
||
00052 ;and that the Auto Mode would have issued a command to go to a
|
||
00053 ;lower range. Obviously in Manual Mode you want to be able to
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 2
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00054 ;change capacitances being measured, and at such a time the value
|
||
00055 ;being measured will temporarily go to zero, causing this feature
|
||
00056 ;to kick in.
|
||
00057
|
||
00058 ;the rest of the first line is allocated to the display of the current
|
||
00059 ;count. internally a 24 bit counter allows the accumulation of counts
|
||
00060 ;up to 16,777,216. In Auto Mode the AutoRanging kicks in at around
|
||
00061 ;524,288 to range UP, and below 32,768 it shifts DOWN. There are 4
|
||
00062 ;ranges. In the lowest range it allows a display of from .00 pf to
|
||
00063 ;5,242.88 pf. range 2 ranges from 4,096 pf to 524,288 pf. range 3
|
||
00064 ;ranges from .4096 uf to 52.4288 uf. range 4 ranges from 32.768 uf
|
||
00065 ;to 16,777.216 uf.
|
||
00066
|
||
00067 ;in Manual Mode you can generate counts from 0 to 16,777,216
|
||
00068 ;but the accuracy outside the above specified ranges can then
|
||
00069 ;have an error greater than 1%. use autoranging for maximum
|
||
00070 ;accuracy. use Manual Mode when using the Comparison feature
|
||
00071 ;or when you don't want the unit to AutoRange. AutoRanging to zero
|
||
00072 ;always causes the unit to go to range 1 for zero. then when you
|
||
00073 ;attach a new capacitor it may take a few seconds before AutoRanging
|
||
00074 ;detects an aout-of-range condition and responds. by the way, to
|
||
00075 ;speed up from such zero excursions I have implemented the UP Range
|
||
00076 ;portion of the AutoRange so that it always goes to range 4. I do
|
||
00077 ;this because it is always quicker to down range than it is to up
|
||
00078 ;range. there is method to my madness!
|
||
00079
|
||
00080 ;values are displayed properly positioned over the value identifiers
|
||
00081 ;such as uf nf and pf. a space is provided between each set of 3
|
||
00082 ;digits to reflect standard engineering notation. partial number
|
||
00083 ;sets are padded with _ to the right. numbers have leading zeros
|
||
00084 ;suppressed up to the decimal point. commas are added where they are
|
||
00085 ;appropriate.
|
||
00086
|
||
00087 ;note that sometimes many more digits are displayed than the accuracy
|
||
00088 ;warrants. in general you can trust the first 3 digits to be right
|
||
00089 ;on. the 4th digit is normally accurate +/- 1 count. additional
|
||
00090 ;digits are displayed not for additional accuracy, but simply because
|
||
00091 ;they are useful for watching variations due to temperature, etc.,
|
||
00092 ;and they are useful in matching two or more capacitors.
|
||
00093
|
||
00094 ;basic accuracy is 1% or better within the AutoRanging values
|
||
00095 ;up to about 100 uf. by the time you get a measurement like
|
||
00096 ;16,000.000 uf the time to collect such a measurement has risen to
|
||
00097 ;almost 24 seconds. this causes the accumulated error to rise
|
||
00098 ;to a few percent.
|
||
00099
|
||
00100 ;the first position on the second line will display a number from
|
||
00101 ;1 to 4. this represents the current range, where 1 is the lowest
|
||
00102 ;range. the middle section of the second line contains the uf
|
||
00103 ;nf and pf indicators, positioned directly below the numeric groups
|
||
00104 ;that they refer to. I chose to display more than one set of
|
||
00105 ;indicators so you can easily read something like:
|
||
00106 ;
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 3
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00107 ;+ 12,000.___
|
||
00108 ;2 fd nf pf A**
|
||
00109 ;
|
||
00110 ;as either .012 uf 12.000 nf or 12,000 pf.
|
||
00111
|
||
00112 ;after the uf/nf/pf indicators there is either an "A" or an "M"
|
||
00113 ;displayed as an indicator of either Manual or Auto Mode being
|
||
00114 ;active. this is followed by two locations that display an
|
||
00115 ;animated (moving) black box to indicate that a new count is
|
||
00116 ;in progress. this is replaced by ** to indicate that the
|
||
00117 ;on-screen count has just been updated. These asterisks will
|
||
00118 ;remain on-screen until the circuitry detects edge synchronization.
|
||
00119 ;then the flashing black boxes appear. to speed up the
|
||
00120 ;synchronization process I have separate routines for handling
|
||
00121 ;rising and falling edges.
|
||
00122
|
||
00123 ;occassionaly you will see a message such as "OVER-RANGE!" when
|
||
00124 ;in the manual mode. if the number is still displayed, then this is
|
||
00125 ;just a cautionary warning that the displayed value lies outside
|
||
00126 ;the range where it can be guaranteed to be 1% accurate.
|
||
00127 ;if the message is the *only* thing displayed on the screen,
|
||
00128 ;then you have exceeded the 16 million count limit and really
|
||
00129 ;need to switch to a higher range.
|
||
00130 ;
|
||
00131 ;during AutoRanging a quick flash of the word "AUTORANGING" will
|
||
00132 ;appear, and you may hear a click from the internal relays. some
|
||
00133 ;ranges switch without the click sound because they are using
|
||
00134 ;external counters to switch ranges.
|
||
00135
|
||
00136 ;a note of caution when using Manual Mode: if you have set the
|
||
00137 ;device to operate in Comparison Mode by pressing the ZERO
|
||
00138 ;button, this zero comparison value will be retained *for the
|
||
00139 ;current numbered range* even if you move to another scale.
|
||
00140 ;before moving to another scale it is therefore a good idea
|
||
00141 ;to remove the cap being measured and press the ZERO button to
|
||
00142 ;re-zero the scale. if you don't do this, then the next time
|
||
00143 ;you return to that range the Comparison value will again
|
||
00144 ;be in effect. there is nothing wrong with bridging a comparison
|
||
00145 ;over two different ranges. if you want to do that, you
|
||
00146 ;have to press the ZERO button at *each* range you want to
|
||
00147 ;perform the comparison on.
|
||
00148
|
||
00149 ;because the ZERO button automatically causes entry into the
|
||
00150 ;Manual Mode, you usually can't run Comparison Mode in
|
||
00151 ;Auto Mode. however, *if* you hit the reset button and have
|
||
00152 ;a capacitor attached, the reset auto-zero feature will
|
||
00153 ;cause the current cap value to be subtracted on *every* range.
|
||
00154 ;this works with values up to about 1 uf with no problem.
|
||
00155 ;larger values will cause overflow errors on the lower ranges
|
||
00156 ;and may therefore give erroneous readings. also note that the
|
||
00157 ;time required to perfom the auto-zero function increases
|
||
00158 ;with increasing external capacitance. if the cap value is more than
|
||
00159 ;a few uf then the auto-zero logic may cause the circuitry to
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 4
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00160 ;cycle endlessly in an attempt to zero the lower ranges.
|
||
00161 ;if that happens, remove the capacitor and perform a reset.
|
||
00162
|
||
00163
|
||
00164
|
||
00165
|
||
00166
|
||
00167 ;
|
||
00168 ; directives
|
||
00169 ;
|
||
00170
|
||
00171
|
||
00172 ;
|
||
00173 ; note: written in all lower case so case sensitivity doesn't matter.
|
||
00174 ; however: set assembler to case-insensitive, except within strings using /c- option
|
||
00175 ;
|
||
00176
|
||
00177 ;
|
||
00178 ; directives
|
||
00179 ;
|
||
00180
|
||
00181
|
||
00182
|
||
00183 LIST P=PIC16F84 ;this directive must come first
|
||
00184
|
||
00185 ; instead of using the [ include <16f84.inc> ] we have placed the contents of the
|
||
00186 ; microchip supplied include file below for documentation purposes.
|
||
00187 ;
|
||
00188 ; P16F84.INC Standard Header File, Version 2.00 Microchip Technology, Inc.
|
||
00189
|
||
00190 ; This header file defines configurations, registers, and other useful bits of
|
||
00191 ; information for the PIC16F84 microcontroller. These names are taken to match
|
||
00192 ; the data sheets as closely as possible.
|
||
00193
|
||
00194 ; Note that the processor must be selected before this file is
|
||
00195 ; included. The processor may be selected the following ways:
|
||
00196
|
||
00197 ; 1. Command line switch:
|
||
00198 ; C:\ MPASM MYFILE.ASM /PIC16F84
|
||
00199 ; 2. LIST directive in the source file
|
||
00200 ; LIST P=PIC16F84
|
||
00201 ; 3. Processor Type entry in the MPASM full-screen interface
|
||
00202 ;==========================================================================
|
||
00203 ;
|
||
00204 ; Verify Processor
|
||
00205 ;
|
||
00206 ;==========================================================================
|
||
00207
|
||
00208 IFNDEF __16F84
|
||
00209 MESSG "Processor-header file mismatch. Verify selected processor."
|
||
00210 ENDIF
|
||
00211
|
||
00212 ;==========================================================================
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 5
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00213 ;
|
||
00214 ; Register Definitions
|
||
00215 ;
|
||
00216 ;==========================================================================
|
||
00217
|
||
00000000 00218 W EQU H'0000'
|
||
00000001 00219 F EQU H'0001'
|
||
00220
|
||
00221 ;----- Register Files------------------------------------------------------
|
||
00222
|
||
00000000 00223 INDF EQU H'0000'
|
||
00000001 00224 TMR0 EQU H'0001'
|
||
00000002 00225 PCL EQU H'0002'
|
||
00000003 00226 STATUS EQU H'0003'
|
||
00000004 00227 FSR EQU H'0004'
|
||
00000005 00228 PORTA EQU H'0005'
|
||
00000006 00229 PORTB EQU H'0006'
|
||
00000008 00230 EEDATA EQU H'0008'
|
||
00000009 00231 EEADR EQU H'0009'
|
||
0000000A 00232 PCLATH EQU H'000A'
|
||
0000000B 00233 INTCON EQU H'000B'
|
||
00234
|
||
00000081 00235 OPTION_REG EQU H'0081'
|
||
00000085 00236 TRISA EQU H'0085'
|
||
00000086 00237 TRISB EQU H'0086'
|
||
00000088 00238 EECON1 EQU H'0088'
|
||
00000089 00239 EECON2 EQU H'0089'
|
||
00240
|
||
00241 ;----- STATUS Bits --------------------------------------------------------
|
||
00242
|
||
00000007 00243 IRP EQU H'0007'
|
||
00000006 00244 RP1 EQU H'0006'
|
||
00000005 00245 RP0 EQU H'0005'
|
||
00000004 00246 NOT_TO EQU H'0004'
|
||
00000003 00247 NOT_PD EQU H'0003'
|
||
00000002 00248 Z EQU H'0002'
|
||
00000001 00249 DC EQU H'0001'
|
||
00000000 00250 C EQU H'0000'
|
||
00251
|
||
00252 ;----- INTCON Bits --------------------------------------------------------
|
||
00253
|
||
00000007 00254 GIE EQU H'0007'
|
||
00000006 00255 EEIE EQU H'0006'
|
||
00000005 00256 T0IE EQU H'0005'
|
||
00000004 00257 INTE EQU H'0004'
|
||
00000003 00258 RBIE EQU H'0003'
|
||
00000002 00259 T0IF EQU H'0002'
|
||
00000001 00260 INTF EQU H'0001'
|
||
00000000 00261 RBIF EQU H'0000'
|
||
00262
|
||
00263 ;----- OPTION Bits --------------------------------------------------------
|
||
00264
|
||
00000007 00265 NOT_RBPU EQU H'0007'
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 6
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00000006 00266 INTEDG EQU H'0006'
|
||
00000005 00267 T0CS EQU H'0005'
|
||
00000004 00268 T0SE EQU H'0004'
|
||
00000003 00269 PSA EQU H'0003'
|
||
00000002 00270 PS2 EQU H'0002'
|
||
00000001 00271 PS1 EQU H'0001'
|
||
00000000 00272 PS0 EQU H'0000'
|
||
00273
|
||
00274 ;----- EECON1 Bits --------------------------------------------------------
|
||
00275
|
||
00000004 00276 EEIF EQU H'0004'
|
||
00000003 00277 WRERR EQU H'0003'
|
||
00000002 00278 WREN EQU H'0002'
|
||
00000001 00279 WR EQU H'0001'
|
||
00000000 00280 RD EQU H'0000'
|
||
00281
|
||
00282 ;==========================================================================
|
||
00283 ;
|
||
00284 ; RAM Definition
|
||
00285 ;
|
||
00286 ;==========================================================================
|
||
00287
|
||
000000CF 00288 __MAXRAM H'CF'
|
||
00289 __BADRAM H'07', H'50'-H'7F', H'87'
|
||
00290
|
||
00291 ;==========================================================================
|
||
00292 ;
|
||
00293 ; Configuration Bits
|
||
00294 ;
|
||
00295 ;==========================================================================
|
||
00296
|
||
0000000F 00297 _CP_ON EQU H'000F'
|
||
00003FFF 00298 _CP_OFF EQU H'3FFF'
|
||
00003FF7 00299 _PWRTE_ON EQU H'3FF7'
|
||
00003FFF 00300 _PWRTE_OFF EQU H'3FFF'
|
||
00003FFF 00301 _WDT_ON EQU H'3FFF'
|
||
00003FFB 00302 _WDT_OFF EQU H'3FFB'
|
||
00003FFC 00303 _LP_OSC EQU H'3FFC'
|
||
00003FFD 00304 _XT_OSC EQU H'3FFD'
|
||
00003FFE 00305 _HS_OSC EQU H'3FFE'
|
||
00003FFF 00306 _RC_OSC EQU H'3FFF'
|
||
00307
|
||
00308
|
||
00309 ;end of <include> file stuff
|
||
00310
|
||
00311 ;define stuff that microchip in their wisdom re-named.
|
||
00312 ; this is in case we use the identifiers in the original data sheets by accident
|
||
00313
|
||
00000000 00314 IND0 EQU H'00' ;file address. microchip calls it indf
|
||
00000001 00315 RTCC EQU H'01' ;file address. microchip calls it tmr0
|
||
00316 ;
|
||
00317 ;<<option in mpasm is an opcode, and so not allowed as a file address name>>
|
||
00318 ;option equ h'81' ;file address. microchip calls it option_reg
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 7
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00319 ;
|
||
00000004 00320 TO EQU H'04' ;status. microchip calls it not_to
|
||
00000003 00321 PD EQU H'03' ;status. microchip calls it not_pd
|
||
00000005 00322 RTIE EQU H'05' ;intcon. microchip calls it t0ie
|
||
00000002 00323 RTIF EQU H'02' ;intcon. microchip calls it t0if
|
||
00000007 00324 RBPU EQU H'07' ;option_reg. microchip calls it not_rbpu
|
||
00000005 00325 RTS EQU H'05' ;option_reg. microchip calls it t0cs
|
||
00000004 00326 RTE EQU H'04' ;option_reg. microchip calls it t0se
|
||
00327
|
||
00328
|
||
00329
|
||
00330 ;we have to set the configuration bits
|
||
00331 ; __config a & b & c
|
||
00332 ; _rc_osc, _xt_osc, _hs_osc, _lp_osc oscillator type
|
||
00333 ; _wdt_on, _wdt_off watchdog timer
|
||
00334 ; _cp_on, _cp_off code protect
|
||
00335 ; _pwrte_on, _pwrte_off power up timer enable
|
||
00336
|
||
2007 3FF1 00337 __CONFIG _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF
|
||
00338 ;configure pic as desired...
|
||
00339
|
||
00340 ;
|
||
00341 ;constant equates
|
||
00342 ;
|
||
00343
|
||
003D0900 00344 XTAL_FREQ = D'4000000' ;crystal frequency
|
||
000F4240 00345 CLOCK = XTAL_FREQ/4 ;base operating frequency
|
||
00346
|
||
00347 ;portb definitions (also shadowb)
|
||
00348
|
||
00000007 00349 DB7 = H'07' ;outb lcd db7 (msb)
|
||
00000006 00350 DB6 = H'06' ;outb lcd db6
|
||
00000005 00351 DB5 = H'05' ;outb lcd db5
|
||
00000004 00352 DB4 = H'04' ;outb lcd db4
|
||
00000003 00353 LCDRS = H'03' ;outb lcd rs line (data/!instruction)
|
||
00000002 00354 LCDE = H'02' ;outb lcd enable line
|
||
00000001 00355 PSELECT = H'01' ;outb period select
|
||
00356 ; 0=period 1=px100
|
||
00000000 00357 PERIODIN = H'00' ;inb selected period input
|
||
00358
|
||
00359 ;porta definitions (also acopy)
|
||
00360
|
||
00000000 00361 CONTROLA = H'00' ;outa 0=x1 1=rangex100
|
||
00000001 00362 CONTROLB = H'01' ;outa period 0=period 1=period/10
|
||
00000002 00363 ZEROKEY = H'02' ;[wt] causes zero compare at current range
|
||
00000003 00364 DOWNKEY = H'03' ;[bk] causes move to next lower range
|
||
00000004 00365 UPKEY = H'04' ;[gn] causes move to next higher range
|
||
00366
|
||
00367 ;character equates
|
||
00368
|
||
000000E4 00369 MU = H'e4' ;greek letter on lcd for uf
|
||
00000020 00370 FLIPCHAR = ' '
|
||
000000FF 00371 FLOPCHAR = H'ff' ;big black box on lcd
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 8
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00372
|
||
00373
|
||
00374 ;
|
||
00375 ;eeprom data area 64x8 at h'2100'
|
||
00376 ;you can store stuff like serial numbers and id codes here.
|
||
00377 ;use de directives to specify data to be stored.
|
||
00378
|
||
00379 ;in this project eeprom is used only to hold copyright notice.
|
||
00380
|
||
2100 00381 ORG H'2100' ;set data eeprom origin
|
||
00382
|
||
2100 0043 006F 0070 00383 EXAMPLE DE "Copyright 1999. Designed and Written by Fr. Tom McGahee"
|
||
0079 0072 0069
|
||
0067 0068 0074
|
||
0020 0031 0039
|
||
0039 0039 002E
|
||
0020 0044 0065
|
||
0073 0069 0067
|
||
006E 0065 0064
|
||
0020 0061 006E
|
||
0064 0020 0057
|
||
0072 0069 0074
|
||
0074 0065 006E
|
||
0020 0062 0079
|
||
0020 0046 0072
|
||
002E 0020 0054
|
||
006F 006D 0020
|
||
004D 006
|
||
00384
|
||
00385
|
||
00386 ;
|
||
00387 ;define ram useage
|
||
00388 ;
|
||
00389
|
||
00390
|
||
00391 ;h'0c' is where general purpose sram begins, and ends at h'4f'. room for 68 bytes.
|
||
00392
|
||
00393 ;we use cblock statements to define variable space in sram.
|
||
00394
|
||
00395 ;ram data storage declarations
|
||
00396
|
||
00397
|
||
00398 CBLOCK H'0c'
|
||
00399
|
||
0000000C 00400 SAVEW ;for inthandler
|
||
0000000D 00401 SAVESTATUS ;for inthandler
|
||
0000000E 00402 SAVEFSR ;for inthandler
|
||
0000000F 00403 TEMP0 ;gp: also used for mantissa
|
||
00000010 00404 TEMP1 ;general purpose
|
||
00000011 00405 TEMP2 ;general purpose
|
||
00000012 00406 TEMP3 ;gp: also used for exponent
|
||
00000013 00407 XMILLISEC ;register for timer operations
|
||
00000014 00408 YMILLISEC ;2nd register for timer operations
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 9
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00409
|
||
00000015 00410 ACOPY ;temp copy of "a" for input of buttons
|
||
00000016 00411 SHADOWB ;port b shadow register
|
||
00000017 00412 WLCDTEMP ;lcd temp for w
|
||
00000018 00413 NIBBLES ;lcd nibbles and controls are assembled here
|
||
00414
|
||
00415
|
||
00000019 00416 X10 ;lsb of packed decimal digits.
|
||
0000001A 00417 X32 ; later, digits are shifted to make room for
|
||
0000001B 00418 X54 ; spaces, comma, and decimal point
|
||
0000001C 00419 X76 ; lsb of digit set is low part of byte
|
||
0000001D 00420 X98
|
||
0000001E 00421 XBA
|
||
0000001F 00422 XDC
|
||
00000020 00423 XFE ;msb of decimal digits
|
||
00424
|
||
00425
|
||
00000021 00426 FLAGS ;flags (see below for assignments)
|
||
00000022 00427 AUTOFLAGS ;autorange flags (see below)
|
||
00428
|
||
00000023 00429 BIN24_0 ;24 bit binary version of current count
|
||
00000024 00430 BIN24_1
|
||
00000025 00431 BIN24_2
|
||
00432
|
||
00000026 00433 OFFSETX ;pointer to current offset group
|
||
00434
|
||
00000027 00435 OFFSET_0 ;zero adjust and comparison register
|
||
00000028 00436 OFFSET_1 ; for +/- comparisons.
|
||
00000029 00437 OFFSET_2
|
||
00438
|
||
0000002A 00439 OFFSET1_0 ;zero adjust for lowest scale
|
||
0000002B 00440 OFFSET1_1
|
||
0000002C 00441 OFFSET1_2
|
||
00442
|
||
0000002D 00443 OFFSET2_0 ;zero adjust for second scale
|
||
0000002E 00444 OFFSET2_1
|
||
0000002F 00445 OFFSET2_2
|
||
00446
|
||
00000030 00447 OFFSET3_0 ;zero adjust for third scale
|
||
00000031 00448 OFFSET3_1
|
||
00000032 00449 OFFSET3_2
|
||
00450
|
||
00000033 00451 OFFSET4_0 ;zero adjust for highest scale
|
||
00000034 00452 OFFSET4_1
|
||
00000035 00453 OFFSET4_2
|
||
00454
|
||
00000036 00455 OVER_0 ;overflow binary counter
|
||
00000037 00456 OVER_1 ; tells us when sync wait is too long
|
||
00000038 00457 OVER_2
|
||
00458
|
||
00459 ENDC
|
||
00460
|
||
00461 ;aliases: these allow alternate name for systems resources.
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 10
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00462 ; it makes reading the program a bit easier while conserving resources
|
||
00463
|
||
00000019 00464 XLSB = X10
|
||
00000020 00465 XMSB = XFE
|
||
00000010 00466 SHIFT = TEMP1
|
||
00000017 00467 DROP = WLCDTEMP
|
||
0000000F 00468 MANTISSA = TEMP0
|
||
00000012 00469 EXPONENT = TEMP3
|
||
00470
|
||
00471 ;shadowb: bit assignments
|
||
00472
|
||
00473 ;LOW 4 BITS ARE SHADOW FOR PORTB (Some have already been defined)
|
||
00474
|
||
00475 ;periodin = h'00' ;inb selected period input
|
||
00476 ; (not used, but still registered)
|
||
00477 ;pselect = h'01' ;outb period select
|
||
00478 ; 0=period 1=px100
|
||
00479 ;lcde = h'02' ;outb lcd enable line
|
||
00480 ;lcdrs = h'03' ;outb lcd rs line (data/!instruction)
|
||
00481
|
||
00482 ;flags: bit assignments
|
||
00483
|
||
00000000 00484 INTOVERFLOW = H'0' ;1=overflow during interrupt routine
|
||
00485 ; = h'1' ;not used
|
||
00486 ; = h'2' ;not used
|
||
00000003 00487 GOTIT = H'3' ;1=we have data
|
||
00000004 00488 PLUSMINUS = H'4' ;1=plus [bin24 > offset]
|
||
00000005 00489 FLIPFLOP = H'5' ;flipflop indicator
|
||
00490 ; = h'6' ;not used
|
||
00491 ; = h'7' ;not used
|
||
00492
|
||
00493 ;autoflags: bit assignments
|
||
00494
|
||
00000000 00495 MANUAL = H'0' ;1=manual 0=auto
|
||
00000001 00496 STOP = H'1' ;1=stop 0=continue operation
|
||
00000002 00497 RANGECHANGE = H'2' ;1=range change
|
||
00000003 00498 TOOLONG = H'3' ;1=too long
|
||
00499
|
||
00500 ;conversions used by decimal nibble output routines
|
||
00501
|
||
00000000 00502 N0 = H'0'
|
||
00000001 00503 N1 = H'1'
|
||
00000002 00504 N2 = H'2'
|
||
00000003 00505 N3 = H'3'
|
||
00000004 00506 N4 = H'4'
|
||
00000005 00507 N5 = H'5'
|
||
00000006 00508 N6 = H'6'
|
||
00000007 00509 N7 = H'7'
|
||
00000008 00510 N8 = H'8'
|
||
00000009 00511 N9 = H'9'
|
||
0000000A 00512 NSPACE = H'a' ;after number is produced
|
||
0000000B 00513 NPLUS = H'b' ; we add in special characters
|
||
0000000C 00514 NMINUS = H'c'
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 11
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
0000000D 00515 NCOMMA = H'd'
|
||
0000000E 00516 NPERIOD = H'e'
|
||
0000000F 00517 NX = H'f'
|
||
00518
|
||
00519
|
||
00520 ;
|
||
00521 ;program 1kx14 eeprom. (h'400') can only be changed via programmer, not on-the-fly.
|
||
00522 ;
|
||
00523
|
||
00524
|
||
0000 00525 ORG H'0000' ;set code origin
|
||
00526
|
||
0000 289E 00527 START GOTO SETUP ;we have to get past interrupt vector at 0004
|
||
00528
|
||
00529
|
||
00530
|
||
00531 ;
|
||
00532 ;interrupts
|
||
00533 ; there is a single interrupt location at 004
|
||
00534 ; we must use flags to determine which interrupt...
|
||
00535 ; this info is in intcon
|
||
00536 ;
|
||
00537 ;intcon register: byte assignments
|
||
00538 ;
|
||
00539 ;enables... 1=enable 0=disable
|
||
00540 ;<7>=gie=global_int_enable
|
||
00541 ;<6>=eeie=eeprom_int_enable
|
||
00542 ;<5>=t0ie=t0_int_enable (enables <2> t0if)
|
||
00543 ;<4>=inte=int_enable (rb0/int) (enables <1> intf)
|
||
00544 ;<3>=rbie=rb_int_enable (enables <0> rbif)
|
||
00545 ;
|
||
00546 ;flags. software reset. 0=reset 1=flagged
|
||
00547 ;<2>=t0if=t0_int_flag
|
||
00548 ;<1>=intf=int_flag (rb0/int)
|
||
00549 ;<0>=rbif=rb_int_flag (rb7-rb4)
|
||
00550 ;
|
||
00551 ;upon power up and !mclr!, intcon will contain 0000 000x
|
||
00552 ;this means that initially all interrupts are disabled.
|
||
00553 ;
|
||
00554 ;note: option_reg register is used to program use of tmr0 and wdt
|
||
00555 ;
|
||
00556
|
||
0004 00557 ORG H'0004' ;interrupt vector location
|
||
00558
|
||
0004 00559 INTHANDLER
|
||
00560 ;global interrupts automatically disabled on entry!
|
||
00561 ;we must save context using a somewhat convoluted scheme
|
||
0004 008C 00562 MOVWF SAVEW ;save w register!
|
||
0005 0E03 00563 SWAPF STATUS,W ;save status! (twisted)
|
||
0006 008D 00564 MOVWF SAVESTATUS ;(we use swapf so as not to disturb Z!)
|
||
0007 0804 00565 MOVF FSR,W ;save fsr!
|
||
0008 008E 00566 MOVWF SAVEFSR
|
||
00567
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 12
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00568 ;actual interrupt code
|
||
0009 0801 00569 MOVF TMR0,W ;save tmr0 in case we need it
|
||
000A 00A3 00570 MOVWF BIN24_0 ;save it as low byte
|
||
000B 1D0B 00571 BTFSS INTCON,T0IF ;if not t0if it should be intf
|
||
000C 2816 00572 GOTO INTPERIOD
|
||
000D 00573 INTTMR0
|
||
000D 110B 00574 BCF INTCON,T0IF ;reset t0if
|
||
000E 0AA4 00575 INCF BIN24_1,F ;update 24 bit binary count
|
||
000F 1D03 00576 BTFSS STATUS,Z ;need carry?
|
||
0010 2818 00577 GOTO INTRETURN ;all done.
|
||
0011 0AA5 00578 INCF BIN24_2,F ;handled carry.
|
||
0012 1D03 00579 BTFSS STATUS,Z ;overflow?
|
||
0013 2818 00580 GOTO INTRETURN ;if not, almost done
|
||
0014 2126 00581 CALL SET4 ;otherwise range to top
|
||
0015 1421 00582 BSF FLAGS,INTOVERFLOW ;set overflow indicator
|
||
00583 ;now flow into intperiod to terminate
|
||
00584 ; and turn off interrupts
|
||
00585
|
||
00586
|
||
00587 ;intperiod occurs when rbo/int triggers on edge (intf)
|
||
00588 ; (it is also entered when there is an overflow!)
|
||
0016 00589 INTPERIOD
|
||
0016 15A1 00590 BSF FLAGS,GOTIT ;tell regular program we have data!
|
||
0017 018B 00591 CLRF INTCON ;turn off all interrupts
|
||
00592 ;& clear all interrupt flags
|
||
00593
|
||
0018 00594 INTRETURN
|
||
0018 0905 00595 COMF PORTA,W ;copy inverted porta to w
|
||
0019 391C 00596 ANDLW B'00011100' ;check three bits at once
|
||
001A 1903 00597 BTFSC STATUS,Z
|
||
001B 281E 00598 GOTO INTFINISH ;if all are low, then none pushed
|
||
001C 0805 00599 MOVF PORTA,W
|
||
001D 0095 00600 MOVWF ACOPY ;save copy of porta for later use
|
||
00601 ;sort out the details later...
|
||
00602
|
||
00603
|
||
001E 00604 INTFINISH
|
||
001E 080E 00605 MOVF SAVEFSR,W ;restore fsr!
|
||
001F 0084 00606 MOVWF FSR
|
||
0020 0E0D 00607 SWAPF SAVESTATUS,W ;untwist twisted saved status
|
||
0021 0083 00608 MOVWF STATUS ;restore normalized status!
|
||
0022 0E8C 00609 SWAPF SAVEW,F ;restore w! first twist nibbles
|
||
0023 0E0C 00610 SWAPF SAVEW,W ;then twist again and place result in w.
|
||
00611 ;(how convoluted!)
|
||
00612
|
||
00613
|
||
0024 0009 00614 RETFIE ;return from interrupt!
|
||
00615 ;gie is auto-re-enabled.
|
||
00616
|
||
00617
|
||
00618 ;note that jump tables and decoder tables are limited to 256 bytes of program space,
|
||
00619 ;and care must be taken that tables not cross over page boundaries.
|
||
00620 ;the limitation is based on the 8 bit addressing scheme employed in tables due to
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 13
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00621 ;the size of w.
|
||
00622
|
||
00623 ;decoder tables take the form:
|
||
00624 ;label
|
||
00625 ; addwf pcl,f ;this executes an effective jump forward
|
||
00626 ; retlw 'a' ;0 decodes as 'a'
|
||
00627 ; retlw 'b' ;1 decodes as 'b'
|
||
00628 ; retlw 'c' ;2 decodes as 'c' ... and so on
|
||
00629 ;
|
||
00630 ;
|
||
00631
|
||
00632
|
||
00633 ;convert special packed bcd+ nibbles into one of 16 8 bit code things
|
||
00634
|
||
0025 00635 CONVERT
|
||
0025 390F 00636 ANDLW B'00001111' ;just the right nibble, please
|
||
0026 0782 00637 ADDWF PCL,F ;this executes an effective jump forward 0-15
|
||
0027 3430 00638 RETLW '0'
|
||
0028 3431 00639 RETLW '1'
|
||
0029 3432 00640 RETLW '2'
|
||
002A 3433 00641 RETLW '3'
|
||
002B 3434 00642 RETLW '4'
|
||
002C 3435 00643 RETLW '5'
|
||
002D 3436 00644 RETLW '6'
|
||
002E 3437 00645 RETLW '7'
|
||
002F 3438 00646 RETLW '8'
|
||
0030 3439 00647 RETLW '9'
|
||
0031 3420 00648 RETLW ' ' ;decode the special stuff, too
|
||
0032 342B 00649 RETLW '+'
|
||
0033 342D 00650 RETLW '-'
|
||
0034 342C 00651 RETLW ','
|
||
0035 342E 00652 RETLW '.'
|
||
0036 345F 00653 RETLW '_' ;underscore _ used for non-existent digits
|
||
00654
|
||
00655 ;text for lcd messages
|
||
00656
|
||
0037 00657 SOMETEXT ;routine to extract string pieces
|
||
0037 0782 00658 ADDWF PCL,F ;this executes an effective jump forward
|
||
0038 00659 STARTTEXT
|
||
0038 3450 3449 3443 00660 BEGIN1TEXT DT "PIC CAP METER",0 ;put *your* name or message here 16 max
|
||
3420 3443 3441
|
||
3450 3420 344D
|
||
3445 3454 3445
|
||
3452 3400
|
||
0046 3446 3472 3420 00661 BEGIN2TEXT DT "Fr Tom McGahee",0 ;put *your* name or message here 16 max
|
||
3454 346F 346D
|
||
3420 344D 3463
|
||
3447 3461 3468
|
||
3465 3465 3400
|
||
0055 3441 3455 3454 00662 AUTOTEXT DT "AUTORANGING ",0
|
||
344F 3452 3441
|
||
344E 3447 3449
|
||
344E 3447 3420
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 14
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
3420 3420 3420
|
||
3420 3400
|
||
0066 344F 3456 3445 00663 OVERTEXT DT "OVER-RANGE!",0
|
||
3452 342D 3452
|
||
3441 344E 3447
|
||
3445 3421 3400
|
||
0072 344D 3441 344E 00664 MANUAL2TEXT DT "MANUAL MODE",0
|
||
3455 3441 344C
|
||
3420 344D 344F
|
||
3444 3445 3400
|
||
007E 3420 3420 3420 00665 FOURSPACES DT " "
|
||
3420
|
||
0082 3420 34E4 3466 00666 UFNFPFTEXT DT " ",MU,"f nf pf",0 ;that mu is code for greek letter
|
||
3420 3420 346E
|
||
3466 3420 3420
|
||
3470 3466 3400
|
||
008E 345A 3445 3452 00667 ZEROTEXT DT "ZERO ALL RANGES",0
|
||
344F 3420 3441
|
||
344C 344C 3420
|
||
3452 3441 344E
|
||
3447 3445 3453
|
||
3400
|
||
00668
|
||
00669
|
||
00000066 00670 COMMONTEXT = OVERTEXT ;share text to conserve memory
|
||
00671 ;(every little "bit" counts!)
|
||
00672 ;if you need extra bytes you can
|
||
00673 ;reduce the size of the messages,
|
||
00674 ;or even eliminate some entirely.
|
||
00675 ;but leave fourspaces and ufnfpftext alone,
|
||
00676 ;or at least modify them with care!
|
||
00677
|
||
00678
|
||
00679
|
||
00680 ; pic16c84 pinouts
|
||
00681 ;
|
||
00682 ; ra2 <1> <18> ra1
|
||
00683 ; ra3 <2> <17> ra0
|
||
00684 ; (oc) ra4/tmr0<3> <16> osc1/clkin
|
||
00685 ; !mclr! <4> <15> osc2/clkout
|
||
00686 ; gnd <5> <14> +2 to +6 volts
|
||
00687 ; rb0/int <6> <13> rb7
|
||
00688 ; rb1 <7> <12> rb6
|
||
00689 ; rb2 <8> <11> rb5
|
||
00690 ; rb3 <9> <10> rb4
|
||
00691 ;
|
||
00692 ;osc1 & osc2 allow many types of timing choices. use device command to select.
|
||
00693 ;
|
||
00694 ;!mclr! tied high via resistor. use a switch to force it low for a reset.
|
||
00695 ;
|
||
00696 ;ra4 becomes the tmr0 external input if option_reg<5>=1. then option_reg<4> selects edge.
|
||
00697 ;ra4 is not ttl. it is oc out and schmitt in. use pullup resistor if needed.
|
||
00698 ;
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 15
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00699 ;ra3-ra0 are ttl level.
|
||
00700 ;
|
||
00701 ;rb7-rb0 are ttl. weak pullups can be programmed for inputs if option_reg<7>=0
|
||
00702 ;rb0/int acts as int pin if intcon<4> inte=1. intcon<1> intf is flag. software reset.
|
||
00703 ;rb7-rb4 will generate an interrupt if intcon<3> rbie=1. intcon<0> rbif is flag. software reset.
|
||
00704 ;
|
||
00705
|
||
00706
|
||
009E 00707 SETUP ;initialize ports and registers
|
||
00708
|
||
00709 ;ra4/tmr0<3>, ra3<2>, ra2<1>, ra1<18>, ra0<17>
|
||
00710 ;rb7<13>, rb6<12>, rb5<11>, rb4<10>
|
||
00711 ;rb3<9>, rb2<8>, rb1<7>, rb0/int<6>
|
||
00712
|
||
00713 ;page 1 stuff includes option_reg, trisa, trisb, eecon1, eecon2
|
||
00714
|
||
00715
|
||
009E 1683 00716 BSF STATUS,RP0 ;allow access to page 1 stuff!
|
||
00717 ;*************** ignore mplab message[302]
|
||
009F 301C 00718 MOVLW B'00011100' ;set porta direction for i/o pins
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00A0 0085 00719 MOVWF TRISA ;0=output 1=input
|
||
00720
|
||
00A1 3001 00721 MOVLW B'00000001' ;set portb direction for i/o pins
|
||
00722 ;using rb0 as interrupt pin.
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00A2 0086 00723 MOVWF TRISB ;0=output 1=input
|
||
00724
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00A3 1381 00725 BCF OPTION_REG,NOT_RBPU ;!rbpu! rb_pullup 0=enabled 1=disabled
|
||
00726 ; enabling is based on individual port-latch values
|
||
00727 ; we have disabled rb_pullup
|
||
00728
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00A4 1301 00729 BCF OPTION_REG,INTEDG ;intedg 0=inc on falling 1=inc on rising
|
||
00730 ; <<note: intedg and t0se use opposite definition!>>
|
||
00731 ;we are incrementing on falling edge
|
||
00732 ; because initial sync is on falling edge
|
||
00733 ; and we want full period
|
||
00734 ;
|
||
00735 ;the edge used is later changed to speed
|
||
00736 ;up sync process.
|
||
00737
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00A5 1281 00738 BCF OPTION_REG,T0CS ;t0cs timer0clocksource 0=internal clkout 1=ra4/int
|
||
00739 ; (rts in some data sheets)
|
||
00740 ; we clear so we can use internal clkout
|
||
00741
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00A6 1201 00742 BCF OPTION_REG,T0SE ;t0se timer0signaledge 0=inc on rising 1=inc on falling
|
||
00743 ; (rte in some data sheets)
|
||
00744 ; <<note: intedg and t0se use opposite definition!>>
|
||
00745 ; in our application edge makes no difference,
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 16
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00746 ; so we arbitrarily choose rising edge.
|
||
00747
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00A7 1581 00748 BSF OPTION_REG,PSA ;psa prescalerassignment 0=tmr0 1=wdt
|
||
00749 ;we do not use wdt, but we set prescaler
|
||
00750 ;to wdt to allow div by 1 for tmr0!
|
||
00751
|
||
00752 ;ps2-ps0 determine prescalerrate, which is
|
||
00753 ;dependent also on whether tmr0 or wdt is selected:
|
||
00754 ;wdt from 0-7 is div by 1 2 4 8 16 32 64 128
|
||
00755 ;tmr0 from 0-7 is div by 2 4 8 16 32 64 128 256
|
||
00756 ;if wdt is assigned prescaler, then tmr0 is div by 1
|
||
00757 ; here we will set prescaler to divide by 1 for tmr0
|
||
00758 ; by assigning the prescaler to the wdt
|
||
00759
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00A8 1101 00760 BCF OPTION_REG,PS2 ;ps2 set for division by 1
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00A9 1081 00761 BCF OPTION_REG,PS1 ;ps1
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
00AA 1001 00762 BCF OPTION_REG,PS0 ;ps0
|
||
00763 ;***************
|
||
00AB 1283 00764 BCF STATUS,RP0 ;allow access to page 0 stuff again. (back to normal)
|
||
00765
|
||
00766 ;now use movlw/movwf and/or clrf statements to initialize any desired variables
|
||
00767
|
||
00AC 01A1 00768 CLRF FLAGS ;reset all flag bits
|
||
00AD 01A2 00769 CLRF AUTOFLAGS
|
||
00AE 30FF 00770 MOVLW B'11111111' ;ensure initial 1's to allow auto-zero!
|
||
00AF 0095 00771 MOVWF ACOPY
|
||
00772
|
||
00773 ;ready now to begin main user program.
|
||
00774
|
||
00B0 00775 MAINPROG
|
||
00B0 238B 00776 CALL LCDRESET ;reset lcd, set for 4 bit ops, clear, no cursor
|
||
00777
|
||
00778 ;output opening two-line message and wait 2 seconds to allow circuitry to stabilize.
|
||
00779
|
||
00B1 3000 00780 MOVLW BEGIN1TEXT-STARTTEXT
|
||
00B2 2332 00781 CALL TEXTOUT
|
||
00B3 23B1 00782 CALL LCDHOME2
|
||
00B4 300E 00783 MOVLW BEGIN2TEXT-STARTTEXT
|
||
00B5 2332 00784 CALL TEXTOUT
|
||
00B6 23E9 00785 CALL DELAY1000
|
||
00B7 23E9 00786 CALL DELAY1000
|
||
00787
|
||
00B8 23A5 00788 CALL LCDCLEAR ;clear lcd and display "ZERO ALL" message
|
||
00B9 3056 00789 MOVLW ZEROTEXT-STARTTEXT
|
||
00BA 2332 00790 CALL TEXTOUT
|
||
00791
|
||
00792 ;set each range and perform initial Auto-Zero for each scale (click click click)
|
||
00793
|
||
00BB 210C 00794 CALL SET1
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 17
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00BC 2108 00795 CALL SETSTUFF
|
||
00796
|
||
00BD 2116 00797 CALL SET2
|
||
00BE 2108 00798 CALL SETSTUFF
|
||
00799
|
||
00BF 211C 00800 CALL SET3
|
||
00C0 2108 00801 CALL SETSTUFF
|
||
00802
|
||
00C1 2126 00803 CALL SET4
|
||
00C2 2108 00804 CALL SETSTUFF
|
||
00805
|
||
00806 ;finished with all the initialization stuff. so here we go loop de loop!
|
||
00807
|
||
00C3 00808 MAINLOOP
|
||
00C3 2277 00809 CALL PERIODINIT ;sync and acquire a count
|
||
00C4 20D3 00810 CALL CHECKHIT ;check for buttons and process
|
||
00811
|
||
00C5 00812 PROCESSDATA
|
||
00C5 018B 00813 CLRF INTCON ;disable interrupts (we have other work to do)
|
||
00C6 1C21 00814 BTFSS FLAGS,INTOVERFLOW ;check state of interrupt overflow flag
|
||
00C7 2986 00815 GOTO CONVERTIT ;if no overflow, convert binary, etc.
|
||
00C8 00816 OVERFLOWED
|
||
00C8 23A5 00817 CALL LCDCLEAR ;if interrupt overflow
|
||
00C9 302E 00818 MOVLW OVERTEXT-STARTTEXT ; clear display and show message
|
||
00CA 2332 00819 CALL TEXTOUT
|
||
00CB 28C3 00820 GOTO MAINLOOP ;try again!
|
||
00821
|
||
00822 ;subroutine to check for buttons being hit while interrupts are off
|
||
00823
|
||
00CC 00824 GETHIT
|
||
00CC 0905 00825 COMF PORTA,W ;copy inverted porta to w
|
||
00CD 391C 00826 ANDLW B'00011100' ;check three bits at once
|
||
00CE 1903 00827 BTFSC STATUS,Z
|
||
00CF 0008 00828 RETURN ;if all are low, then none pushed
|
||
00D0 0805 00829 MOVF PORTA,W
|
||
00D1 0095 00830 MOVWF ACOPY ;save copy of original porta for later use
|
||
00831 ;sort out the details later...
|
||
00D2 28D9 00832 GOTO OLDHIT
|
||
00833
|
||
00834 ;subroutine to handle buttons being hit both in and out of interrupt.
|
||
00835 ;includes immediate check and check for "old" hits registered in acopy.
|
||
00836
|
||
00D3 00837 CHECKHIT
|
||
00838 ;first check for new hit key
|
||
00D3 0905 00839 COMF PORTA,W ;copy inverted porta to w
|
||
00D4 391C 00840 ANDLW B'00011100' ;check three bits at once
|
||
00D5 1903 00841 BTFSC STATUS,Z
|
||
00D6 28D9 00842 GOTO OLDHIT ;if all are low, then none pushed
|
||
00D7 0805 00843 MOVF PORTA,W ;otherwise we have a new hit!
|
||
00D8 0095 00844 MOVWF ACOPY ;save copy of porta for later use by oldhit
|
||
00845 ;liesurely flow into oldhit routine...
|
||
00D9 00846 OLDHIT
|
||
00D9 0915 00847 COMF ACOPY,W ;check if a key was hit (old or new)
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 18
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00DA 391C 00848 ANDLW B'00011100' ;check three bits at once
|
||
00DB 1903 00849 BTFSC STATUS,Z
|
||
00DC 0008 00850 RETURN ;if all are low, then none pushed
|
||
00DD 1022 00851 BCF AUTOFLAGS,MANUAL ;clear manual so we can use setx routines!
|
||
00DE 1A15 00852 BTFSC ACOPY,UPKEY ;non-inverted original in acopy. is it UP key?
|
||
00DF 28EE 00853 GOTO ISITDOWN ;1 means it was NOT UP key, so check next key
|
||
00E0 00854 ITWASUP ;0 means it WAS UP key
|
||
00E0 0826 00855 MOVF OFFSETX,W ;ummmm, where ARE we? (what range is current?)
|
||
00E1 3C2A 00856 SUBLW OFFSET1_0 ;compare by subtracting one from the other
|
||
00E2 1D03 00857 BTFSS STATUS,Z ;are we at range 1?
|
||
00E3 28E6 00858 GOTO UPTO3 ;if not, check for others...
|
||
00E4 00859 UPTO2
|
||
00E4 2116 00860 CALL SET2 ;if it was 1, change to range 2
|
||
00E5 2900 00861 GOTO HITDONE ;clean up and continue
|
||
00E6 00862 UPTO3
|
||
00E6 0826 00863 MOVF OFFSETX,W ;it's 2/3/4. Figure out which...
|
||
00E7 3C2D 00864 SUBLW OFFSET2_0 ;compare by subtracting
|
||
00E8 1D03 00865 BTFSS STATUS,Z
|
||
00E9 28EC 00866 GOTO UPTO4 ;if not a match on 2, it must be 3/4
|
||
00EA 00867 ITWAS2
|
||
00EA 211C 00868 CALL SET3 ;if it was 2, change range to 3
|
||
00EB 2900 00869 GOTO HITDONE ;clean up and continue
|
||
00EC 00870 UPTO4
|
||
00871
|
||
00EC 2126 00872 CALL SET4 ;if it was 3 go to 4.
|
||
00873 ;if it was already 4, stay at 4. (sticky button)
|
||
00ED 2900 00874 GOTO HITDONE ;clean up and continue
|
||
00875
|
||
00876 ;ahh, it wasn't the UP button. So check for DOWN or ZERO button...
|
||
00877
|
||
00EE 00878 ISITDOWN
|
||
00EE 1995 00879 BTFSC ACOPY,DOWNKEY ;non-inverted original in acopy
|
||
00EF 28FE 00880 GOTO ISZERO ;if it wasn't DOWN, it was ZERO!
|
||
00F0 00881 ITWASDOWN
|
||
00F0 0826 00882 MOVF OFFSETX,W ;Down from *where*? 4/3/2/1
|
||
00F1 3C33 00883 SUBLW OFFSET4_0 ;compare by subtracting
|
||
00F2 1D03 00884 BTFSS STATUS,Z
|
||
00F3 28F6 00885 GOTO DOWNTO2 ;if it wasn't 4 it was 3/2/1
|
||
00F4 00886 DOWNTO3
|
||
00F4 211C 00887 CALL SET3 ;if it was 4, down range to 3
|
||
00F5 2900 00888 GOTO HITDONE ;clean up and continue
|
||
00F6 00889 DOWNTO2
|
||
00F6 0826 00890 MOVF OFFSETX,W ;maybe it is at 3?
|
||
00F7 3C30 00891 SUBLW OFFSET3_0
|
||
00F8 1D03 00892 BTFSS STATUS,Z
|
||
00F9 28FC 00893 GOTO DOWNTO1 ;if not it is 2/1
|
||
00894
|
||
00FA 2116 00895 CALL SET2 ;if it was 3, go down to 2
|
||
00FB 2900 00896 GOTO HITDONE ;clean up and continue
|
||
00FC 00897 DOWNTO1
|
||
00FC 210C 00898 CALL SET1 ;2 goes down to 1. sticky button at 1
|
||
00FD 2900 00899 GOTO HITDONE
|
||
00FE 00900 ISZERO
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 19
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
00FE 2277 00901 CALL PERIODINIT ;before we can perform a zeroing operation
|
||
00902 ; we must first acquire a clean reading!
|
||
00FF 2130 00903 CALL SETZEROX ;then we do the zero stuff
|
||
00904 ;and liesurely flow into the cleanup part below.
|
||
00905
|
||
00906 ;clean up and continue
|
||
00907
|
||
0100 00908 HITDONE
|
||
0100 0905 00909 COMF PORTA,W ;copy inverted porta to w
|
||
0101 391C 00910 ANDLW B'00011100' ;check three bits at once
|
||
0102 1D03 00911 BTFSS STATUS,Z
|
||
0103 2900 00912 GOTO HITDONE ;wait for key release!
|
||
0104 30FF 00913 MOVLW B'11111111'
|
||
0105 0095 00914 MOVWF ACOPY ;"reset" acopy to indicate it is processed.
|
||
0106 1422 00915 BSF AUTOFLAGS,MANUAL ;force manual mode
|
||
0107 28C3 00916 GOTO MAINLOOP ;messes up stack, but who cares?
|
||
00917 ;this method allows quicker response
|
||
00918
|
||
00919 ;exiting from a called subroutine by
|
||
00920 ;executing a goto is frowned upon by some,
|
||
00921 ;but in this case it is the simplest way
|
||
00922 ;to speed up the response. it effectively
|
||
00923 ;terminates the current loop and goes to the
|
||
00924 ;beginning of mainloop.
|
||
00925
|
||
00926 ;following subroutine is used by initialization routine to auto-zero each range
|
||
00927
|
||
0108 00928 SETSTUFF
|
||
0108 23ED 00929 CALL XMILLISECS
|
||
0109 2277 00930 CALL PERIODINIT
|
||
010A 2130 00931 CALL SETZEROX
|
||
010B 2BAA 00932 GOTO LCDCLEAR2
|
||
00933
|
||
00934 ;subroutines to set circuitry to handle a particular range. Range switching stuff.
|
||
00935
|
||
010C 00936 SET1
|
||
010C 1822 00937 BTFSC AUTOFLAGS,MANUAL ;normally in manual mode you don't auto-range.
|
||
010D 0008 00938 RETURN ; this is over-ridden if button is pushed.
|
||
010E 302A 00939 MOVLW OFFSET1_0 ;offsetx is loaded with appropriate pointer value
|
||
010F 00A6 00940 MOVWF OFFSETX
|
||
0110 1496 00941 BSF SHADOWB,PSELECT ;ports are set to turn appropriate external
|
||
00942 ; circuitry on/off to select desired range
|
||
00943
|
||
00944 ;some code is shared between set1 and set2
|
||
00945 ;strictly to save code space.
|
||
0111 00946 SET1_2
|
||
0111 0816 00947 MOVF SHADOWB,W
|
||
0112 0086 00948 MOVWF PORTB
|
||
00949
|
||
0113 1005 00950 BCF PORTA,CONTROLA
|
||
0114 1085 00951 BCF PORTA,CONTROLB
|
||
0115 0008 00952 RETURN
|
||
00953
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 20
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
0116 00954 SET2
|
||
0116 1822 00955 BTFSC AUTOFLAGS,MANUAL
|
||
0117 0008 00956 RETURN
|
||
0118 302D 00957 MOVLW OFFSET2_0
|
||
0119 00A6 00958 MOVWF OFFSETX
|
||
011A 1096 00959 BCF SHADOWB,PSELECT
|
||
011B 2911 00960 GOTO SET1_2
|
||
00961
|
||
011C 00962 SET3
|
||
011C 1822 00963 BTFSC AUTOFLAGS,MANUAL
|
||
011D 0008 00964 RETURN
|
||
011E 1096 00965 BCF SHADOWB,PSELECT
|
||
011F 0816 00966 MOVF SHADOWB,W
|
||
0120 0086 00967 MOVWF PORTB
|
||
00968
|
||
0121 1405 00969 BSF PORTA,CONTROLA
|
||
0122 1085 00970 BCF PORTA,CONTROLB
|
||
0123 3030 00971 MOVLW OFFSET3_0
|
||
0124 00A6 00972 MOVWF OFFSETX
|
||
0125 0008 00973 RETURN
|
||
00974
|
||
0126 00975 SET4
|
||
0126 1822 00976 BTFSC AUTOFLAGS,MANUAL
|
||
0127 0008 00977 RETURN
|
||
0128 1096 00978 BCF SHADOWB,PSELECT
|
||
0129 0816 00979 MOVF SHADOWB,W
|
||
012A 0086 00980 MOVWF PORTB
|
||
00981
|
||
012B 1405 00982 BSF PORTA,CONTROLA
|
||
012C 1485 00983 BSF PORTA,CONTROLB
|
||
012D 3033 00984 MOVLW OFFSET4_0
|
||
012E 00A6 00985 MOVWF OFFSETX
|
||
012F 0008 00986 RETURN
|
||
00987
|
||
00988 ;subroutine to perform zero function by copying current contents of bin24 counter
|
||
00989 ; to local register set. Later the contents of the local set are subtracted from
|
||
00990 ; whatever the new current count is, and this effects the Zero or Comparison function.
|
||
00991
|
||
0130 00992 SETZEROX
|
||
0130 0826 00993 MOVF OFFSETX,W ;recover current offset group
|
||
0131 0084 00994 MOVWF FSR ;use indirect addressing
|
||
0132 0823 00995 MOVF BIN24_0,W ;zero by copying bin24 to offset
|
||
0133 0080 00996 MOVWF INDF
|
||
0134 0A84 00997 INCF FSR,F
|
||
0135 0824 00998 MOVF BIN24_1,W
|
||
0136 0080 00999 MOVWF INDF
|
||
0137 0A84 01000 INCF FSR,F
|
||
0138 0825 01001 MOVF BIN24_2,W
|
||
0139 0080 01002 MOVWF INDF
|
||
013A 0008 01003 RETURN
|
||
01004
|
||
01005 ;subroutine to subtract current offset from current bin24 count.
|
||
01006 ; allows Zeroing and Comparing.
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 21
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
01007 ;
|
||
01008 ;I do not claim that this implementation is minimal or fastest method to do this.
|
||
01009 ; I can only say that it works. (I need to get SOME sleep, guys!).
|
||
01010 ; writing code at 2 AM is not always conducive to achieving conciseness. ZZZZzzzzzz.
|
||
01011
|
||
013B 01012 SUBTRACTOFFSET
|
||
013B 0829 01013 MOVF OFFSET_2,W
|
||
013C 0225 01014 SUBWF BIN24_2,W ;see which is biggest
|
||
013D 1903 01015 BTFSC STATUS,Z
|
||
013E 2942 01016 GOTO EQUAL_2 ;equal so far
|
||
013F 01017 NOTEQUAL
|
||
013F 1803 01018 BTFSC STATUS,C ;c=1 means bin24 bigger
|
||
0140 2950 01019 GOTO BIN24BIGGER
|
||
0141 2967 01020 GOTO OFFSETBIGGER
|
||
0142 01021 EQUAL_2
|
||
0142 0828 01022 MOVF OFFSET_1,W
|
||
0143 0224 01023 SUBWF BIN24_1,W ;see which is biggest
|
||
0144 1903 01024 BTFSC STATUS,Z
|
||
0145 2947 01025 GOTO EQUAL_1 ;equal so far
|
||
0146 293F 01026 GOTO NOTEQUAL ;carry bit tells all...
|
||
0147 01027 EQUAL_1
|
||
01028
|
||
0147 0827 01029 MOVF OFFSET_0,W
|
||
0148 0223 01030 SUBWF BIN24_0,W ;see which is biggest
|
||
0149 1903 01031 BTFSC STATUS,Z
|
||
014A 294C 01032 GOTO EQUAL_0 ;equal so far
|
||
014B 293F 01033 GOTO NOTEQUAL ;carry bit tells all...
|
||
014C 01034 EQUAL_0
|
||
014C 01A3 01035 CLRF BIN24_0 ;so clear bin24
|
||
014D 01A4 01036 CLRF BIN24_1
|
||
014E 01A5 01037 CLRF BIN24_2
|
||
014F 0008 01038 RETURN
|
||
01039
|
||
0150 01040 BIN24BIGGER
|
||
0150 1621 01041 BSF FLAGS,PLUSMINUS ;bigger is +
|
||
0151 01042 BB0
|
||
0151 0827 01043 MOVF OFFSET_0,W
|
||
0152 02A3 01044 SUBWF BIN24_0,F ;place result in bin24
|
||
0153 1903 01045 BTFSC STATUS,Z
|
||
0154 295D 01046 GOTO BB1 ;if zero skip to next byte
|
||
0155 1803 01047 BTFSC STATUS,C
|
||
0156 295D 01048 GOTO BB1 ;if result was + skip to next byte
|
||
0157 01049 BB0NEG
|
||
01050
|
||
01051
|
||
01052 ;handle negative
|
||
0157 3001 01053 MOVLW 1 ;"borrow" one from next byte
|
||
0158 02A4 01054 SUBWF BIN24_1,F
|
||
0159 1803 01055 BTFSC STATUS,C ;if negative (no cy) we need another
|
||
01056 ; borrow from next byte.
|
||
015A 295D 01057 GOTO BB1 ;if positive, do next byte
|
||
01058
|
||
015B 3001 01059 MOVLW 1 ;then "borrow" one from next byte
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 22
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
015C 02A5 01060 SUBWF BIN24_2,F
|
||
01061
|
||
01062
|
||
015D 01063 BB1
|
||
01064
|
||
015D 0828 01065 MOVF OFFSET_1,W ;subtract second byte set
|
||
015E 02A4 01066 SUBWF BIN24_1,F ;place result in bin24
|
||
015F 1903 01067 BTFSC STATUS,Z
|
||
0160 2964 01068 GOTO BB2 ;if zero skip to next byte
|
||
0161 1803 01069 BTFSC STATUS,C
|
||
0162 2964 01070 GOTO BB2 ;if result was + skip to next byte
|
||
0163 01071 BB1NEG
|
||
01072 ;handle negative
|
||
0163 03A5 01073 DECF BIN24_2,F ;"borrow" one from next byte
|
||
01074 ;that was last byte, so no more borrows
|
||
0164 01075 BB2
|
||
01076
|
||
0164 0829 01077 MOVF OFFSET_2,W ;subtract last byte set
|
||
0165 02A5 01078 SUBWF BIN24_2,F ;place result in bin24
|
||
01079 ;this is msb so we is done
|
||
0166 0008 01080 RETURN ;result is in bin24 set
|
||
01081
|
||
01082
|
||
0167 01083 OFFSETBIGGER
|
||
01084
|
||
01085 ;so subtract bin24 from offset
|
||
0167 0827 01086 MOVF OFFSET_0,W
|
||
01087 ;swap those buggers!
|
||
0168 008F 01088 MOVWF TEMP0 ;use temp0
|
||
0169 0823 01089 MOVF BIN24_0,W
|
||
016A 00A7 01090 MOVWF OFFSET_0
|
||
016B 080F 01091 MOVF TEMP0,W
|
||
016C 00A3 01092 MOVWF BIN24_0 ;swapped. tempset has offset.
|
||
01093
|
||
016D 0828 01094 MOVF OFFSET_1,W
|
||
01095 ;swap those buggers!
|
||
016E 0090 01096 MOVWF TEMP1 ;use temp1
|
||
016F 0824 01097 MOVF BIN24_1,W
|
||
0170 00A8 01098 MOVWF OFFSET_1
|
||
0171 0810 01099 MOVF TEMP1,W
|
||
0172 00A4 01100 MOVWF BIN24_1 ;swapped. tempset has offset.
|
||
01101
|
||
0173 0829 01102 MOVF OFFSET_2,W
|
||
01103 ;swap those buggers!
|
||
0174 0091 01104 MOVWF TEMP2 ;use temp2
|
||
0175 0825 01105 MOVF BIN24_2,W
|
||
0176 00A9 01106 MOVWF OFFSET_2
|
||
0177 0811 01107 MOVF TEMP2,W
|
||
0178 00A5 01108 MOVWF BIN24_2 ;swapped. temporary set has offset.
|
||
01109
|
||
0179 2150 01110 CALL BIN24BIGGER ;re-use code!
|
||
017A 1221 01111 BCF FLAGS,PLUSMINUS ;except plusminus is different!
|
||
01112 ; (hey, it works!)
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 23
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
01113
|
||
017B 080F 01114 MOVF TEMP0,W ;recover offset set
|
||
017C 00A7 01115 MOVWF OFFSET_0 ;0
|
||
01116
|
||
01117
|
||
017D 0810 01118 MOVF TEMP1,W
|
||
017E 00A8 01119 MOVWF OFFSET_1 ;1
|
||
01120
|
||
01121
|
||
017F 0811 01122 MOVF TEMP2,W
|
||
0180 00A9 01123 MOVWF OFFSET_2 ;2
|
||
0181 23AD 01124 CALL LCDHOME1
|
||
0182 30FF 01125 MOVLW H'ff' ;flash the negative sign to attract attention
|
||
0183 23BC 01126 CALL LCDOUT
|
||
0184 23ED 01127 CALL XMILLISECS ;just a little flash...
|
||
0185 0008 01128 RETURN
|
||
01129
|
||
01130 ;subroutine to convert binary results into human readable format on lcd
|
||
01131
|
||
0186 01132 CONVERTIT
|
||
0186 01133 COPYZERO ;set up indirect adressing to recover stuff
|
||
0186 0826 01134 MOVF OFFSETX,W ;recover current offset group
|
||
0187 0084 01135 MOVWF FSR ;use indirect addressing
|
||
0188 0800 01136 MOVF INDF,W ;get first element
|
||
0189 00A7 01137 MOVWF OFFSET_0 ;copy it
|
||
01138
|
||
018A 0A84 01139 INCF FSR,F ;point to next element
|
||
018B 0800 01140 MOVF INDF,W ;get 2nd element
|
||
018C 00A8 01141 MOVWF OFFSET_1 ;copy it
|
||
01142
|
||
018D 0A84 01143 INCF FSR,F ;point to next element
|
||
018E 0800 01144 MOVF INDF,W ;get 3rd element
|
||
018F 00A9 01145 MOVWF OFFSET_2 ;copy it
|
||
01146
|
||
0190 213B 01147 CALL SUBTRACTOFFSET ;perform zero/compare
|
||
01148
|
||
01149
|
||
01150
|
||
01151 ;bin2dec: converts bin24 to decimal in xlsb->xmsb registers.
|
||
01152 ;method I chose to use nibble bcd. to get speed up I use a hybrid
|
||
01153 ;approach to doing the conversions. I designed a decimal adder that
|
||
01154 ;allows me to add a decimal value by specifying its mantissa and
|
||
01155 ;exponent values. binary conversions proceed by converting binary
|
||
01156 ;bits to decimal mantissa/exponent form and then adding the
|
||
01157 ;mantissa/exponent pieces. I did not choose this method because it
|
||
01158 ;is elegant, optimal, or whatever. I chose it because it was something
|
||
01159 ;I had been playing around with as a mental exercise, and I decided
|
||
01160 ;to use the results of my investigations here in this project.
|
||
01161 ;so, if some of the code seems a bit strange to you, don't worry.
|
||
01162 ;it seems a bit strange to me, too! But, hey, it works, and I had
|
||
01163 ;some mental FUN trying this out.
|
||
01164
|
||
0191 01165 BIN2DEC
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 24
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
0191 01166 BYTE0
|
||
0191 0823 01167 MOVF BIN24_0,W ;test for zero
|
||
0192 1903 01168 BTFSC STATUS,Z
|
||
0193 2999 01169 GOTO BYTE1 ;if zero, skip & do next byte
|
||
0194 0090 01170 MOVWF TEMP1 ;leave original alone
|
||
01171
|
||
0195 01172 BYTE0LOOP ;first the onesies
|
||
01173
|
||
01174
|
||
0195 22FC 01175 CALL ADDTENS10 ;mantissa is 1 exponent is 0. one.
|
||
0196 0390 01176 DECF TEMP1,F ;byte is finished when zero
|
||
0197 1D03 01177 BTFSS STATUS,Z
|
||
0198 2995 01178 GOTO BYTE0LOOP
|
||
01179
|
||
0199 01180 BYTE1 ;then groups of 256
|
||
0199 0824 01181 MOVF BIN24_1,W ;test for zero
|
||
019A 1903 01182 BTFSC STATUS,Z
|
||
019B 29AA 01183 GOTO BYTE2 ;if zero, skip & do next byte
|
||
019C 0090 01184 MOVWF TEMP1 ;leave original alone
|
||
019D 01185 BYTE1LOOP
|
||
019D 3006 01186 MOVLW 6
|
||
019E 22FD 01187 CALL ADDTENSX0 ;exponent of 0 handled special
|
||
01188
|
||
019F 3005 01189 MOVLW 5
|
||
01A0 008F 01190 MOVWF MANTISSA
|
||
01A1 3001 01191 MOVLW 1
|
||
01A2 22FF 01192 CALL ADDTENSXX
|
||
01193
|
||
01A3 3002 01194 MOVLW 2
|
||
01A4 008F 01195 MOVWF MANTISSA
|
||
01A5 3002 01196 MOVLW 2
|
||
01A6 22FF 01197 CALL ADDTENSXX
|
||
01198
|
||
01A7 0390 01199 DECF TEMP1,F ;byte is finished when zero
|
||
01A8 1D03 01200 BTFSS STATUS,Z
|
||
01A9 299D 01201 GOTO BYTE1LOOP
|
||
01202
|
||
01203
|
||
01AA 01204 BYTE2 ;then groups of 65,536
|
||
01AA 0825 01205 MOVF BIN24_2,W ;test for zero
|
||
01AB 1903 01206 BTFSC STATUS,Z
|
||
01AC 29C3 01207 GOTO BIN2DECDONE ;if zero, all done.
|
||
01AD 0090 01208 MOVWF TEMP1 ;leave original alone
|
||
01AE 01209 BYTE2LOOP
|
||
01AE 3006 01210 MOVLW 6
|
||
01AF 22FD 01211 CALL ADDTENSX0
|
||
01212
|
||
01B0 3003 01213 MOVLW 3
|
||
01B1 008F 01214 MOVWF MANTISSA
|
||
01B2 3001 01215 MOVLW 1
|
||
01B3 22FF 01216 CALL ADDTENSXX
|
||
01217
|
||
01B4 3005 01218 MOVLW 5
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 25
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
01B5 008F 01219 MOVWF MANTISSA
|
||
01B6 3002 01220 MOVLW 2
|
||
01B7 22FF 01221 CALL ADDTENSXX
|
||
01222
|
||
01B8 3005 01223 MOVLW 5
|
||
01B9 008F 01224 MOVWF MANTISSA
|
||
01BA 3003 01225 MOVLW 3
|
||
01BB 22FF 01226 CALL ADDTENSXX
|
||
01227
|
||
01BC 3006 01228 MOVLW 6
|
||
01BD 008F 01229 MOVWF MANTISSA
|
||
01BE 3004 01230 MOVLW 4
|
||
01BF 22FF 01231 CALL ADDTENSXX
|
||
01232
|
||
01233
|
||
01C0 0390 01234 DECF TEMP1,F ;byte is finished when zero
|
||
01C1 1D03 01235 BTFSS STATUS,Z
|
||
01C2 29AE 01236 GOTO BYTE2LOOP
|
||
01237 ;if zero, all done.
|
||
01238
|
||
01C3 01239 BIN2DECDONE ;now we will take the resultant decimal number set
|
||
01240 ; and spread it out so we can add the commas and
|
||
01241 ; decimal points and other stuff.
|
||
01242
|
||
01243
|
||
01244
|
||
01C3 0826 01245 MOVF OFFSETX,W ;determine range, because each range has a
|
||
01C4 3C2A 01246 SUBLW OFFSET1_0 ; different layout for the digits.
|
||
01C5 1D03 01247 BTFSS STATUS,Z
|
||
01C6 29D6 01248 GOTO ISIT2
|
||
01C7 01249 ITS1
|
||
01C7 2357 01250 CALL SD15X ;I use a shift left from here and drop
|
||
01251 ; method to get the pieces arranged and in place.
|
||
01C8 2353 01252 CALL SD12P ; for example, the sd15x routine will position
|
||
01253 ; us at digit position 15, shift all digits left
|
||
01254 ; one place, and then deposit an X at location 15
|
||
01255 ; Oh yeah, X has been replaced by an underscore instead.
|
||
01256 ; it simply looks neater.
|
||
01257
|
||
01258 ;by the way, all this shift and drop stuff takes
|
||
01259 ;place within the bcd register set. once the register
|
||
01260 ;set is arranged as we want, then the whole set
|
||
01261 ;is read into the lcd display.
|
||
01C9 3008 01262 MOVLW D'8'
|
||
01CA 234C 01263 CALL SDXC
|
||
01264
|
||
01CB 234B 01265 CALL SD4C
|
||
01266
|
||
01267
|
||
01CC 23AA 01268 CALL LCDCLEAR2
|
||
01CD 3031 01269 MOVLW '1'
|
||
01CE 23BC 01270 CALL LCDOUT
|
||
01271
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 26
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
01CF 2249 01272 CALL USUAL
|
||
01D0 0825 01273 MOVF BIN24_2,W
|
||
01D1 3C07 01274 SUBLW D'7'
|
||
01D2 1803 01275 BTFSC STATUS,C
|
||
01D3 2A25 01276 GOTO COMMONSTUFF
|
||
01D4 2126 01277 CALL SET4
|
||
01D5 2A24 01278 GOTO COMMONSTUFFR
|
||
01279
|
||
01D6 01280 ISIT2
|
||
01281
|
||
01D6 0826 01282 MOVF OFFSETX,W
|
||
01D7 3C2D 01283 SUBLW OFFSET2_0
|
||
01D8 1D03 01284 BTFSS STATUS,Z
|
||
01D9 29F4 01285 GOTO ISIT3
|
||
01DA 01286 ITS2
|
||
01DA 2357 01287 CALL SD15X
|
||
01288
|
||
01DB 2357 01289 CALL SD15X
|
||
01290
|
||
01DC 2357 01291 CALL SD15X
|
||
01292
|
||
01DD 2353 01293 CALL SD12P
|
||
01294
|
||
01DE 3008 01295 MOVLW D'8'
|
||
01DF 234C 01296 CALL SDXC
|
||
01297
|
||
01E0 234B 01298 CALL SD4C
|
||
01299
|
||
01E1 23AA 01300 CALL LCDCLEAR2
|
||
01E2 3032 01301 MOVLW '2'
|
||
01E3 23BC 01302 CALL LCDOUT
|
||
01303
|
||
01E4 2249 01304 CALL USUAL
|
||
01E5 0825 01305 MOVF BIN24_2,W
|
||
01E6 3C07 01306 SUBLW D'7'
|
||
01E7 1803 01307 BTFSC STATUS,C
|
||
01E8 29EB 01308 GOTO CHECK2LOW
|
||
01E9 2126 01309 CALL SET4
|
||
01EA 2A24 01310 GOTO COMMONSTUFFR
|
||
01EB 01311 CHECK2LOW
|
||
01EB 0825 01312 MOVF BIN24_2,W
|
||
01EC 1D03 01313 BTFSS STATUS,Z
|
||
01ED 2A25 01314 GOTO COMMONSTUFF
|
||
01EE 0824 01315 MOVF BIN24_1,W
|
||
01EF 3C10 01316 SUBLW D'16'
|
||
01F0 1C03 01317 BTFSS STATUS,C
|
||
01F1 2A25 01318 GOTO COMMONSTUFF
|
||
01F2 210C 01319 CALL SET1
|
||
01F3 2A24 01320 GOTO COMMONSTUFFR
|
||
01321
|
||
01322
|
||
01F4 01323 ISIT3
|
||
01324
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 27
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
01F4 0826 01325 MOVF OFFSETX,W
|
||
01F5 3C30 01326 SUBLW OFFSET3_0
|
||
01F6 1D03 01327 BTFSS STATUS,Z
|
||
01F7 2A11 01328 GOTO ITS4
|
||
01F8 01329 ITS3
|
||
01330
|
||
01F8 2357 01331 CALL SD15X ;sd is short for shift and drop
|
||
01F9 2357 01332 CALL SD15X ;sd is short for shift and drop
|
||
01333
|
||
01FA 234F 01334 CALL SD12S ;sd is short for shift and drop
|
||
01335
|
||
01336
|
||
01FB 3008 01337 MOVLW D'8'
|
||
01FC 2354 01338 CALL SDXP ;sd is short for shift and drop
|
||
01339
|
||
01340
|
||
01FD 234B 01341 CALL SD4C ;sd is short for shift and drop
|
||
01342
|
||
01343
|
||
01FE 23AA 01344 CALL LCDCLEAR2
|
||
01FF 3033 01345 MOVLW '3'
|
||
0200 23BC 01346 CALL LCDOUT
|
||
01347
|
||
0201 2247 01348 CALL FOURPLUS
|
||
0202 0825 01349 MOVF BIN24_2,W
|
||
0203 3C07 01350 SUBLW D'7'
|
||
0204 1803 01351 BTFSC STATUS,C
|
||
0205 2A08 01352 GOTO CHECK3LOW
|
||
0206 2126 01353 CALL SET4
|
||
0207 2A24 01354 GOTO COMMONSTUFFR
|
||
0208 01355 CHECK3LOW
|
||
0208 0825 01356 MOVF BIN24_2,W
|
||
0209 1D03 01357 BTFSS STATUS,Z
|
||
020A 2A25 01358 GOTO COMMONSTUFF
|
||
020B 0824 01359 MOVF BIN24_1,W
|
||
020C 3C10 01360 SUBLW D'16'
|
||
020D 1C03 01361 BTFSS STATUS,C
|
||
020E 2A25 01362 GOTO COMMONSTUFF
|
||
020F 2116 01363 CALL SET2
|
||
0210 2A24 01364 GOTO COMMONSTUFFR
|
||
01365
|
||
01366
|
||
0211 01367 ITS4
|
||
01368
|
||
0211 2357 01369 CALL SD15X ;sd is short for shift and drop
|
||
01370
|
||
0212 2357 01371 CALL SD15X
|
||
01372
|
||
0213 2357 01373 CALL SD15X
|
||
01374
|
||
01375
|
||
0214 234F 01376 CALL SD12S
|
||
01377
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 28
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
01378
|
||
0215 3008 01379 MOVLW D'8'
|
||
0216 2354 01380 CALL SDXP
|
||
01381
|
||
0217 234B 01382 CALL SD4C
|
||
01383
|
||
01384
|
||
0218 23AA 01385 CALL LCDCLEAR2
|
||
0219 3034 01386 MOVLW '4'
|
||
021A 23BC 01387 CALL LCDOUT
|
||
01388
|
||
021B 2247 01389 CALL FOURPLUS
|
||
01390
|
||
021C 01391 CHECK4LOW
|
||
021C 0825 01392 MOVF BIN24_2,W
|
||
021D 1D03 01393 BTFSS STATUS,Z
|
||
021E 2A25 01394 GOTO COMMONSTUFF
|
||
021F 0824 01395 MOVF BIN24_1,W
|
||
0220 3C80 01396 SUBLW D'128'
|
||
0221 1C03 01397 BTFSS STATUS,C
|
||
0222 2A25 01398 GOTO COMMONSTUFF
|
||
0223 211C 01399 CALL SET3
|
||
01400 ;now some shared stuff
|
||
0224 01401 COMMONSTUFFR
|
||
0224 1522 01402 BSF AUTOFLAGS,RANGECHANGE
|
||
01403
|
||
01404
|
||
0225 01405 COMMONSTUFF
|
||
0225 224B 01406 CALL ZEROOFF ;suppress useless zeros, commas, etc.
|
||
0226 233B 01407 CALL DATAOUT ;translate & display set on line 1 of lcd
|
||
0227 3000 01408 MOVLW 0
|
||
0228 23AF 01409 CALL LCDADDRESS
|
||
0229 302B 01410 MOVLW '+' ;+/- goes in 1st position, line 1
|
||
022A 1E21 01411 BTFSS FLAGS,PLUSMINUS
|
||
022B 302D 01412 MOVLW '-'
|
||
022C 23BC 01413 CALL LCDOUT
|
||
01414
|
||
022D 304D 01415 MOVLW H'40'+D'13' ;lcdaddress 2nd row
|
||
022E 23AF 01416 CALL LCDADDRESS
|
||
022F 1C22 01417 BTFSS AUTOFLAGS,MANUAL
|
||
0230 2A33 01418 GOTO COMMONA
|
||
0231 304D 01419 MOVLW 'M' ;Manual Mode
|
||
0232 2A34 01420 GOTO COMMONSTAR
|
||
01421
|
||
0233 01422 COMMONA
|
||
0233 3041 01423 MOVLW 'A' ;Auto Mode
|
||
0234 01424 COMMONSTAR
|
||
0234 23BC 01425 CALL LCDOUT
|
||
0235 302A 01426 MOVLW '*' ;two ** indicates a new conversion is completed.
|
||
0236 23BC 01427 CALL LCDOUT
|
||
0237 23BC 01428 CALL LCDOUT
|
||
0238 23ED 01429 CALL XMILLISECS
|
||
0239 1D22 01430 BTFSS AUTOFLAGS,RANGECHANGE ;if range changed, say so
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 29
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
023A 28C3 01431 GOTO MAINLOOP ;begin next period
|
||
023B 1122 01432 BCF AUTOFLAGS,RANGECHANGE ;update flag so we don't do this again.
|
||
023C 23B1 01433 CALL LCDHOME2 ;2nd line of lcd
|
||
023D 301D 01434 MOVLW AUTOTEXT-STARTTEXT ;it *might* be in auto mode
|
||
023E 1822 01435 BTFSC AUTOFLAGS,MANUAL ;or it *could* be in manual mode
|
||
023F 2A42 01436 GOTO MSTUFF
|
||
0240 2332 01437 CALL TEXTOUT ;if auto mode, flash "AUTORANGING"
|
||
0241 28C3 01438 GOTO MAINLOOP
|
||
0242 01439 MSTUFF
|
||
0242 3001 01440 MOVLW 1
|
||
0243 23AF 01441 CALL LCDADDRESS
|
||
0244 304D 01442 MOVLW 'M' ;if manual mode, just flash an "M"
|
||
0245 23BC 01443 CALL LCDOUT
|
||
0246 28C3 01444 GOTO MAINLOOP
|
||
01445
|
||
0247 01446 FOURPLUS
|
||
0247 3046 01447 MOVLW FOURSPACES-STARTTEXT ;some ranges have four spaces first...
|
||
0248 2332 01448 CALL TEXTOUT
|
||
0249 01449 USUAL
|
||
0249 304A 01450 MOVLW UFNFPFTEXT-STARTTEXT ;all have the uf nf stuff
|
||
024A 2B32 01451 GOTO TEXTOUT
|
||
01452
|
||
01453 ;zerooff: scans current ascii contents of decimal nibbles and
|
||
01454 ; replaces leftmost zeros and comma with spaces. stops at decimal point
|
||
01455 ; or first non-zero numeric. zero suppresion and some other stuff.
|
||
01456
|
||
024B 01457 ZEROOFF
|
||
024B 10A2 01458 BCF AUTOFLAGS,STOP ;start off enabled to scan
|
||
024C 3021 01459 MOVLW XMSB+1 ;scan from xmsb to xlsb
|
||
024D 0084 01460 MOVWF FSR ;use indirect addressing
|
||
024E 01461 ZEROLOOP
|
||
024E 0384 01462 DECF FSR,F ;update pointer
|
||
024F 0804 01463 MOVF FSR,W
|
||
0250 3C18 01464 SUBLW XLSB-1 ;check if past xlsb
|
||
0251 1903 01465 BTFSC STATUS,Z
|
||
0252 0008 01466 RETURN ;if past xlsb, we is done here
|
||
01467
|
||
0253 18A2 01468 BTFSC AUTOFLAGS,STOP
|
||
0254 0008 01469 RETURN ;done if stop is set
|
||
01470
|
||
0255 225A 01471 CALL LEFTCHECK
|
||
0256 18A2 01472 BTFSC AUTOFLAGS,STOP
|
||
0257 0008 01473 RETURN ;done if stop is set
|
||
0258 2271 01474 CALL RIGHTCHECK
|
||
0259 2A4E 01475 GOTO ZEROLOOP
|
||
025A 01476 LEFTCHECK
|
||
025A 0800 01477 MOVF INDF,W ;w has copy of byte.
|
||
025B 39F0 01478 ANDLW B'11110000' ;look at left nibble only
|
||
025C 0090 01479 MOVWF TEMP1 ;save original...
|
||
025D 0E10 01480 SWAPF TEMP1,W ;check nibble in byte format
|
||
025E 3C00 01481 SUBLW N0 ;was it a leading 0?
|
||
025F 1903 01482 BTFSC STATUS,Z
|
||
0260 2A6B 01483 GOTO SPACEIT ;if so, change to a space.
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 30
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
01484
|
||
0261 0E10 01485 SWAPF TEMP1,W ;get original back into w
|
||
0262 3C0D 01486 SUBLW NCOMMA ;was it a comma?
|
||
0263 1903 01487 BTFSC STATUS,Z
|
||
0264 2A6B 01488 GOTO SPACEIT ;if so, change to a space.
|
||
01489
|
||
01490
|
||
0265 0E10 01491 SWAPF TEMP1,W ;get original back into w
|
||
0266 3C0A 01492 SUBLW NSPACE ;was it a space?
|
||
0267 1903 01493 BTFSC STATUS,Z
|
||
0268 2A6B 01494 GOTO SPACEIT ;if so, leave it a space.
|
||
01495
|
||
0269 14A2 01496 BSF AUTOFLAGS,STOP ;if anything else, then stop
|
||
026A 0008 01497 RETURN
|
||
01498
|
||
026B 01499 SPACEIT
|
||
026B 0E00 01500 SWAPF INDF,W ;get swapped version of original
|
||
026C 39F0 01501 ANDLW B'11110000' ;preserve right nibble (in left)
|
||
026D 380A 01502 IORLW NSPACE ;sneak in nspace
|
||
026E 0080 01503 MOVWF INDF ;save it
|
||
026F 0E80 01504 SWAPF INDF,F ;swap it back to correct form
|
||
0270 0008 01505 RETURN
|
||
01506
|
||
01507
|
||
01508
|
||
0271 01509 RIGHTCHECK
|
||
0271 18A2 01510 BTFSC AUTOFLAGS,STOP
|
||
0272 0008 01511 RETURN
|
||
0273 0E80 01512 SWAPF INDF,F ;swap nibbles
|
||
0274 225A 01513 CALL LEFTCHECK ;and share code!
|
||
0275 0E80 01514 SWAPF INDF,F ;restore order.
|
||
0276 0008 01515 RETURN
|
||
01516
|
||
01517 ; this is the main synchronization section. It is responsible for assuring that we sync in the
|
||
01518 ; shortest possible time. After syncing to the period's edge we sort of twiddle our thumbs
|
||
01519 ; and watch for the flags being set by the interrupt handler. when the flags tell us
|
||
01520 ; something, we handle it. we handle things like taking excessively long, actually getting
|
||
01521 ; a flag that says we have a bin24 count accumulated, etc. we also occasionally check
|
||
01522 ; to see if anyone has pushed any buttons. notice that pushed puttons will terminate
|
||
01523 ; regular program flow and cause (among other things) a new set of readings to be acquired.
|
||
01524
|
||
0277 01525 PERIODINIT
|
||
0277 018B 01526 CLRF INTCON ;disable all interrupts
|
||
0278 22ED 01527 CALL CLEARALLDATA ;clear binary and decimal versions.
|
||
01528 ;also clear over_x counters.
|
||
01529 ;data on lcd remains intact.
|
||
0279 1DA2 01530 BTFSS AUTOFLAGS,TOOLONG ;did interrupt routine say "toolong"?
|
||
027A 2A84 01531 GOTO PERIODINIT2 ;if not, continue...
|
||
027B 23AA 01532 CALL LCDCLEAR2 ;if it *was* toolong, then tell the world!
|
||
027C 301D 01533 MOVLW AUTOTEXT-STARTTEXT ; well, it might be in maual or auto modes,
|
||
027D 1822 01534 BTFSC AUTOFLAGS,MANUAL ; so use different messages for first line
|
||
027E 303A 01535 MOVLW MANUAL2TEXT-STARTTEXT
|
||
027F 2332 01536 CALL TEXTOUT
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 31
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
0280 23EC 01537 CALL DELAY400
|
||
0281 23AA 01538 CALL LCDCLEAR2
|
||
0282 302E 01539 MOVLW COMMONTEXT-STARTTEXT ;and use some shared text for the rest.
|
||
0283 2332 01540 CALL TEXTOUT
|
||
01541
|
||
01542
|
||
0284 01543 PERIODINIT2
|
||
0284 11A2 01544 BCF AUTOFLAGS,TOOLONG ;if we got here we have handled any toolong,
|
||
0285 1021 01545 BCF FLAGS,INTOVERFLOW ; and any overflow, so clear those flags now!
|
||
0286 1806 01546 BTFSC PORTB,PERIODIN ;read periodin to find current state of sync
|
||
0287 2A89 01547 GOTO SYNC1 ;highs go one place, lows another...
|
||
0288 2AAD 01548 GOTO SYNC2
|
||
0289 01549 SYNC1
|
||
0289 1683 01550 BSF STATUS,RP0 ;allow access to page 1 stuff!
|
||
01551
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
028A 1301 01552 BCF OPTION_REG,INTEDG ;intedg 0=inc on falling 1=inc on rising
|
||
01553 ; <<note: intedg and t0se use opposite definition!>>
|
||
01554 ;we are incrementing on falling edge
|
||
01555 ; because initial sync is on falling edge
|
||
01556 ; and we want full period
|
||
028B 1283 01557 BCF STATUS,RP0 ;allow access to page 0 stuff again. (normal)
|
||
01558
|
||
028C 1806 01559 BTFSC PORTB,PERIODIN ;read periodin
|
||
028D 2A9D 01560 GOTO SYNCONLOW1
|
||
028E 01561 SYNCONHIGH1
|
||
028E 20CC 01562 CALL GETHIT ;allow buttons
|
||
028F 0AB6 01563 INCF OVER_0,F ;twiddle thumbs, but not for *too* long!
|
||
0290 1D03 01564 BTFSS STATUS,Z
|
||
0291 2A9B 01565 GOTO SYNCONHIGH1B
|
||
0292 0AB7 01566 INCF OVER_1,F
|
||
0293 1D03 01567 BTFSS STATUS,Z
|
||
0294 2A9B 01568 GOTO SYNCONHIGH1B
|
||
0295 0AB8 01569 INCF OVER_2,F
|
||
0296 1D38 01570 BTFSS OVER_2,2
|
||
0297 2A9B 01571 GOTO SYNCONHIGH1B
|
||
0298 15A2 01572 BSF AUTOFLAGS,TOOLONG ;darn! too long! flag it!
|
||
0299 2126 01573 CALL SET4 ;attempt to autorange to highest range.
|
||
029A 2A77 01574 GOTO PERIODINIT
|
||
029B 01575 SYNCONHIGH1B
|
||
029B 1C06 01576 BTFSS PORTB,PERIODIN ;read periodin
|
||
029C 2A8E 01577 GOTO SYNCONHIGH1 ;loop until high
|
||
029D 01578 SYNCONLOW1
|
||
029D 20CC 01579 CALL GETHIT ;allow buttons
|
||
029E 0AB6 01580 INCF OVER_0,F ;twiddle thumbs, but not for *too* long!
|
||
029F 1D03 01581 BTFSS STATUS,Z
|
||
02A0 2AAA 01582 GOTO SYNCONLOW1B
|
||
02A1 0AB7 01583 INCF OVER_1,F
|
||
02A2 1D03 01584 BTFSS STATUS,Z
|
||
02A3 2AAA 01585 GOTO SYNCONLOW1B
|
||
02A4 0AB8 01586 INCF OVER_2,F
|
||
02A5 1D38 01587 BTFSS OVER_2,2
|
||
02A6 2AAA 01588 GOTO SYNCONLOW1B
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 32
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
02A7 15A2 01589 BSF AUTOFLAGS,TOOLONG ;darn! too long! flag it!
|
||
02A8 2126 01590 CALL SET4 ;attempt to autorange to high range
|
||
02A9 2A77 01591 GOTO PERIODINIT
|
||
01592
|
||
02AA 01593 SYNCONLOW1B
|
||
02AA 1806 01594 BTFSC PORTB,PERIODIN ;read periodin
|
||
02AB 2A9D 01595 GOTO SYNCONLOW1 ;loop until low
|
||
02AC 2AD1 01596 GOTO GOTSYNC
|
||
01597
|
||
02AD 01598 SYNC2
|
||
02AD 1683 01599 BSF STATUS,RP0 ;allow access to page 1 stuff!
|
||
01600
|
||
Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct.
|
||
02AE 1701 01601 BSF OPTION_REG,INTEDG ;intedg 0=inc on falling 1=inc on rising
|
||
01602 ; <<note: intedg and t0se use opposite definition!>>
|
||
01603 ;we are incrementing on rising edge
|
||
01604 ; because initial sync is on rising edge
|
||
01605 ; and we want full period
|
||
02AF 1283 01606 BCF STATUS,RP0 ;allow access to page 0 stuff again. (normal)
|
||
01607
|
||
01608
|
||
01609
|
||
01610
|
||
02B0 1806 01611 BTFSC PORTB,PERIODIN ;read periodin
|
||
02B1 2AC1 01612 GOTO SYNCONHIGH2
|
||
02B2 01613 SYNCONLOW2
|
||
02B2 20CC 01614 CALL GETHIT ;allow buttons
|
||
02B3 0AB6 01615 INCF OVER_0,F ;twiddle thumbs, but not *too* long!
|
||
02B4 1D03 01616 BTFSS STATUS,Z
|
||
02B5 2ABF 01617 GOTO SYNCONLOW2B
|
||
02B6 0AB7 01618 INCF OVER_1,F
|
||
02B7 1D03 01619 BTFSS STATUS,Z
|
||
02B8 2ABF 01620 GOTO SYNCONLOW2B
|
||
02B9 0AB8 01621 INCF OVER_2,F
|
||
02BA 1D38 01622 BTFSS OVER_2,2
|
||
02BB 2ABF 01623 GOTO SYNCONLOW2B
|
||
02BC 15A2 01624 BSF AUTOFLAGS,TOOLONG ;darn! too long! flag it!
|
||
02BD 2126 01625 CALL SET4 ;attempt to autorange to high range
|
||
02BE 2A77 01626 GOTO PERIODINIT
|
||
01627
|
||
01628
|
||
02BF 01629 SYNCONLOW2B
|
||
02BF 1806 01630 BTFSC PORTB,PERIODIN ;read periodin
|
||
02C0 2AB2 01631 GOTO SYNCONLOW2 ;loop until low
|
||
02C1 01632 SYNCONHIGH2
|
||
02C1 20CC 01633 CALL GETHIT ;allow buttons
|
||
02C2 0AB6 01634 INCF OVER_0,F ;twiddle thumbs, but not for *too* long!
|
||
02C3 1D03 01635 BTFSS STATUS,Z
|
||
02C4 2ACE 01636 GOTO SYNCONHIGH2B
|
||
02C5 0AB7 01637 INCF OVER_1,F
|
||
02C6 1D03 01638 BTFSS STATUS,Z
|
||
02C7 2ACE 01639 GOTO SYNCONHIGH2B
|
||
02C8 0AB8 01640 INCF OVER_2,F
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 33
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
02C9 1D38 01641 BTFSS OVER_2,2
|
||
02CA 2ACE 01642 GOTO SYNCONHIGH2B
|
||
02CB 15A2 01643 BSF AUTOFLAGS,TOOLONG ;darn! too long! flag it!
|
||
02CC 2126 01644 CALL SET4 ;attempt to autorange to high range
|
||
02CD 2A77 01645 GOTO PERIODINIT
|
||
01646
|
||
01647
|
||
02CE 01648 SYNCONHIGH2B
|
||
02CE 1C06 01649 BTFSS PORTB,PERIODIN ;read periodin
|
||
02CF 2AC1 01650 GOTO SYNCONHIGH2 ;loop until high
|
||
02D0 2AD1 01651 GOTO GOTSYNC
|
||
01652
|
||
02D1 01653 GOTSYNC
|
||
02D1 0181 01654 CLRF TMR0 ;clear timer to eliminate false triggers
|
||
01655 ;periodin just changed.
|
||
02D2 018B 01656 CLRF INTCON ;clear any pending interrupt requests
|
||
01657 ; also clears all enables including gie.
|
||
01658 ; effectively disables all interrupts
|
||
02D3 160B 01659 BSF INTCON,INTE ;enable rb0/int as int
|
||
02D4 168B 01660 BSF INTCON,T0IE ;enable tmr0 interrupt
|
||
01661
|
||
02D5 11A1 01662 BCF FLAGS,GOTIT ;reset indicators
|
||
02D6 1021 01663 BCF FLAGS,INTOVERFLOW
|
||
02D7 178B 01664 BSF INTCON,GIE ;enable global interrupt enable for now...
|
||
02D8 0181 01665 CLRF TMR0 ;clear timer now to reduce latency
|
||
01666
|
||
01667
|
||
02D9 01668 WAITLOOP
|
||
02D9 20CC 01669 CALL GETHIT ;allow buttons
|
||
02DA 304E 01670 MOVLW H'40'+D'14' ;lcdaddress 2nd row
|
||
02DB 23AF 01671 CALL LCDADDRESS
|
||
02DC 1EA1 01672 BTFSS FLAGS,FLIPFLOP ;flip/flop black box
|
||
02DD 2AE4 01673 GOTO FLOP ; to indicate major thumb twiddling in progress
|
||
02DE 01674 FLIP
|
||
02DE 3020 01675 MOVLW FLIPCHAR
|
||
02DF 23BC 01676 CALL LCDOUT
|
||
02E0 30FF 01677 MOVLW FLOPCHAR
|
||
02E1 23BC 01678 CALL LCDOUT
|
||
02E2 12A1 01679 BCF FLAGS,FLIPFLOP
|
||
02E3 2AE9 01680 GOTO GOTITYET
|
||
01681
|
||
02E4 01682 FLOP
|
||
02E4 30FF 01683 MOVLW FLOPCHAR
|
||
02E5 23BC 01684 CALL LCDOUT
|
||
02E6 3020 01685 MOVLW FLIPCHAR
|
||
02E7 23BC 01686 CALL LCDOUT
|
||
02E8 16A1 01687 BSF FLAGS,FLIPFLOP
|
||
01688
|
||
02E9 01689 GOTITYET
|
||
02E9 23ED 01690 CALL XMILLISECS ;delay .2 seconds
|
||
02EA 1DA1 01691 BTFSS FLAGS,GOTIT ;is gotit flag up?
|
||
02EB 2AD9 01692 GOTO WAITLOOP ;wait seemingly forever....
|
||
02EC 0008 01693 RETURN ;WOW! we *finally* have a valid BIN24 ready!
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 34
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
01694
|
||
01695
|
||
01696
|
||
01697 ;clearalldata: clears data xlsb->xmsb and bin24_0/1/2
|
||
01698
|
||
02ED 01699 CLEARALLDATA
|
||
02ED 3019 01700 MOVLW XLSB ;fsr will point to register set
|
||
02EE 0084 01701 MOVWF FSR
|
||
02EF 01702 CLEARLOOP
|
||
02EF 0180 01703 CLRF INDF ;clear a set
|
||
02F0 0A84 01704 INCF FSR,F ;point to next set
|
||
02F1 0804 01705 MOVF FSR,W ;copy next set address to w
|
||
02F2 3C21 01706 SUBLW XMSB+1 ;done when past xmsb
|
||
02F3 1D03 01707 BTFSS STATUS,Z
|
||
02F4 2AEF 01708 GOTO CLEARLOOP ;clear from xlsb to xmsb
|
||
01709
|
||
02F5 01A5 01710 CLRF BIN24_2 ;clear 24 bit binary counter
|
||
02F6 01A4 01711 CLRF BIN24_1
|
||
02F7 01A3 01712 CLRF BIN24_0
|
||
01713
|
||
02F8 01B6 01714 CLRF OVER_0 ;clear 24 bit overflow counter
|
||
02F9 01B7 01715 CLRF OVER_1
|
||
02FA 01B8 01716 CLRF OVER_2
|
||
02FB 0008 01717 RETURN
|
||
01718
|
||
01719 ;shared subroutines to add decimal numbers using mantissa/exponent information
|
||
01720 ; it may not be pretty, but it works!
|
||
01721
|
||
02FC 01722 ADDTENS10
|
||
02FC 3001 01723 MOVLW 1
|
||
02FD 01724 ADDTENSX0
|
||
02FD 008F 01725 MOVWF MANTISSA
|
||
02FE 3000 01726 MOVLW 0
|
||
02FF 01727 ADDTENSXX
|
||
02FF 0092 01728 MOVWF EXPONENT ;exponent
|
||
01729 ;flows into addtens
|
||
01730
|
||
01731 ;addtens: enter with mantissa and exponent registers loaded.
|
||
01732 ;value specified gets added into decimal registers.
|
||
01733 ;w/flags/mantissa/exponent affected. Returns xlsb->xmsb updated.
|
||
01734
|
||
0300 01735 ADDTENS
|
||
0300 080F 01736 MOVF MANTISSA,W ;check mantissa value
|
||
0301 1903 01737 BTFSC STATUS,Z
|
||
0302 0008 01738 RETURN ;return if nothing to do!
|
||
0303 1003 01739 BCF STATUS,C ;clear carry
|
||
0304 0C12 01740 RRF EXPONENT,W ;divide exponent by two (nibble oriented)
|
||
0305 3E19 01741 ADDLW XLSB ;point to proper nibble set
|
||
0306 0084 01742 MOVWF FSR ;use it for indirect addressing of nibble sets
|
||
0307 3EDF 01743 ADDLW -(XMSB+1) ;don't go too far!
|
||
0308 1903 01744 BTFSC STATUS,Z
|
||
0309 0008 01745 RETURN ;return if all available digits done
|
||
030A 1812 01746 BTFSC EXPONENT,0 ;lsb tells us even or odd exponent
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 35
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
030B 2B0F 01747 GOTO ODDSTUFF
|
||
030C 01748 EVENSTUFF
|
||
030C 2312 01749 CALL EVEN ;handle rightmost nibble
|
||
030D 0A92 01750 INCF EXPONENT,F ;prepare for next higher digit
|
||
030E 2B00 01751 GOTO ADDTENS ;see if more to do...
|
||
01752
|
||
030F 01753 ODDSTUFF
|
||
030F 232E 01754 CALL ODD ;handle leftmost nibble
|
||
0310 0A92 01755 INCF EXPONENT,F ;prepare for next higher digit
|
||
0311 2B00 01756 GOTO ADDTENS ;see if more to do...
|
||
0312 01757 EVEN
|
||
0312 300F 01758 MOVLW B'00001111' ;just look at right nibble
|
||
0313 0500 01759 ANDWF INDF,W ; of value pointed to
|
||
0314 078F 01760 ADDWF MANTISSA,F ;add mantissa+current value
|
||
01761 ; and save in mantissa
|
||
0315 080F 01762 MOVF MANTISSA,W ;copy into w, too
|
||
0316 3EF6 01763 ADDLW -D'10' ;same as x-10
|
||
0317 1903 01764 BTFSC STATUS,Z
|
||
0318 2B21 01765 GOTO SETEVENZERO ;10-10=0
|
||
0319 1803 01766 BTFSC STATUS,C
|
||
031A 2B26 01767 GOTO SETEVENPOSITIVE ;cy=1 if x-10 is positive
|
||
031B 01768 SETEVENNEGATIVE
|
||
031B 30F0 01769 MOVLW B'11110000'
|
||
031C 0580 01770 ANDWF INDF,F ;clear out right nibble
|
||
031D 080F 01771 MOVF MANTISSA,W ;copy mantissa+current value into w
|
||
01772 ; (value is less than 10)
|
||
031E 0480 01773 IORWF INDF,F ;now byte contains new right nibble
|
||
031F 018F 01774 CLRF MANTISSA ;clear carryout pointer
|
||
0320 0008 01775 RETURN ;all done! no carryout.
|
||
0321 01776 SETEVENZERO
|
||
0321 30F0 01777 MOVLW B'11110000'
|
||
0322 0580 01778 ANDWF INDF,F ;clear out right nibble
|
||
0323 018F 01779 CLRF MANTISSA ;set mantissa to 1 for carryout.
|
||
0324 0A8F 01780 INCF MANTISSA,F ; 0+1=1
|
||
0325 0008 01781 RETURN ;now update next because of carryout
|
||
0326 01782 SETEVENPOSITIVE
|
||
0326 008F 01783 MOVWF MANTISSA ;save positive value
|
||
0327 30F0 01784 MOVLW B'11110000'
|
||
0328 0580 01785 ANDWF INDF,F ;clear out right nibble
|
||
0329 080F 01786 MOVF MANTISSA,W ;copy mantissa+current value into w
|
||
01787 ; (value is less than 10)
|
||
032A 0480 01788 IORWF INDF,F ;now byte contains new right nibble
|
||
032B 018F 01789 CLRF MANTISSA ;set mantissa to 1 for carryout.
|
||
032C 0A8F 01790 INCF MANTISSA,F ; 0+1=1
|
||
032D 0008 01791 RETURN ;now update next because of carryout
|
||
01792
|
||
032E 01793 ODD
|
||
032E 0E80 01794 SWAPF INDF,F ;swap nibbles
|
||
032F 2312 01795 CALL EVEN ; and use even routines! how sneaky.
|
||
0330 0E80 01796 SWAPF INDF,F ;swap nibbles back to normal
|
||
0331 0008 01797 RETURN ;return with possible carry in mantissa
|
||
01798
|
||
01799
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 36
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
01800
|
||
01801
|
||
01802
|
||
01803 ;sample calling routine
|
||
01804 ; call lcdclear1
|
||
01805 ; movlw onetext-starttext ;note how we subtract starttext address
|
||
01806 ; call textout ; to make an 8 bit address PIC can handle.
|
||
01807 ; call lcdclear2 ; sometext routine and attendant data
|
||
01808 ; movlw twotext-starttext ; should be within 1st 256 bytes of program
|
||
01809 ; call textout ; to ensure addressability.
|
||
01810
|
||
01811
|
||
0332 01812 TEXTOUT
|
||
0332 0090 01813 MOVWF TEMP1 ;save that address!
|
||
0333 01814 TEXTLOOP
|
||
0333 2037 01815 CALL SOMETEXT ;retlw a byte
|
||
0334 3E00 01816 ADDLW 0 ;set z flag if we recovered terminating 0
|
||
0335 1903 01817 BTFSC STATUS,Z
|
||
0336 0008 01818 RETURN ;once we got 0 we are done
|
||
0337 23BC 01819 CALL LCDOUT ;everything else we send to lcd
|
||
0338 0A90 01820 INCF TEMP1,F ;NEXT!
|
||
0339 0810 01821 MOVF TEMP1,W ;need new address in both temp1 and w
|
||
033A 2B33 01822 GOTO TEXTLOOP ;do a whole string of 'em
|
||
01823
|
||
01824 ;routine to output packed bcd+ nibbles
|
||
01825
|
||
033B 01826 DATAOUT
|
||
033B 23AD 01827 CALL LCDHOME1 ;data goes on 1st line of lcd
|
||
033C 3008 01828 MOVLW 8 ;8 bytes = 16 packed bcd+ nibbles
|
||
033D 0091 01829 MOVWF TEMP2 ;temp2 holds byte count
|
||
033E 3020 01830 MOVLW XMSB
|
||
033F 0084 01831 MOVWF FSR ;indirect addressing set to xmsb
|
||
0340 01832 DATALOOP
|
||
0340 0E00 01833 SWAPF INDF,W ;get left nibble, since we are outputting
|
||
01834 ; digits etc from left to right (msb->lsb)
|
||
0341 2025 01835 CALL CONVERT ;convert 4 bits into full regular ascii
|
||
0342 23BC 01836 CALL LCDOUT ;and display it on lcd (including commas, etc.)
|
||
0343 0800 01837 MOVF INDF,W ;then right nibble
|
||
0344 2025 01838 CALL CONVERT
|
||
0345 23BC 01839 CALL LCDOUT
|
||
0346 0384 01840 DECF FSR,F ;point to next
|
||
0347 0391 01841 DECF TEMP2,F
|
||
0348 1903 01842 BTFSC STATUS,Z
|
||
0349 0008 01843 RETURN ;done when all 8 bytes done
|
||
034A 2B40 01844 GOTO DATALOOP ;otherwise keep going.
|
||
01845
|
||
01846
|
||
01847
|
||
01848 ;these routines are used to "shift and drop" coded items such as commas and decimal
|
||
01849 ;points into the packed bcd+ decimal set.
|
||
01850
|
||
01851 ;first we have some space-saving attempts that code some of the more popular sd constructs
|
||
034B 01852 SD4C
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 37
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
034B 3004 01853 MOVLW D'4'
|
||
034C 01854 SDXC
|
||
034C 0090 01855 MOVWF SHIFT
|
||
034D 300D 01856 MOVLW NCOMMA
|
||
034E 2B5A 01857 GOTO SD
|
||
01858
|
||
034F 01859 SD12S
|
||
034F 300C 01860 MOVLW D'12'
|
||
0350 0090 01861 MOVWF SHIFT
|
||
0351 300A 01862 MOVLW NSPACE
|
||
0352 2B5A 01863 GOTO SD
|
||
0353 01864 SD12P
|
||
0353 300C 01865 MOVLW D'12'
|
||
0354 01866 SDXP
|
||
0354 0090 01867 MOVWF SHIFT
|
||
0355 300E 01868 MOVLW NPERIOD
|
||
0356 2B5A 01869 GOTO SD
|
||
0357 01870 SD15X
|
||
0357 300F 01871 MOVLW D'15'
|
||
0358 0090 01872 MOVWF SHIFT
|
||
0359 300F 01873 MOVLW NX
|
||
01874 ;flows into shiftanddrop
|
||
01875
|
||
01876 ;enter with shift position in (shift)temp1 and replacement data in w.
|
||
01877 ;use fsr method. shift left
|
||
01878
|
||
01879 ;the method used for shifting is to shift a nibble at a time
|
||
01880
|
||
035A 01881 SHIFTANDDROP
|
||
035A 01882 SD ;(I use the shorter label when I have to type.)
|
||
035A 0097 01883 MOVWF WLCDTEMP ;steal the lcd's temp register to conserve resources.
|
||
035B 3020 01884 MOVLW XMSB
|
||
035C 0084 01885 MOVWF FSR ;fsr now points to msb
|
||
035D 0810 01886 MOVF TEMP1,W ;check for 'more to do'
|
||
035E 1903 01887 BTFSC STATUS,Z ;if position is 0 no shift to do
|
||
035F 2B71 01888 GOTO STUFFLEFT ; so just stuff data
|
||
0360 01889 NEXTLEFT
|
||
0360 0E80 01890 SWAPF INDF,F ;otherwise 'shift' nibble left
|
||
0361 0800 01891 MOVF INDF,W
|
||
0362 39F0 01892 ANDLW B'11110000' ;clear right nibble
|
||
0363 0080 01893 MOVWF INDF ;of current byte
|
||
0364 0390 01894 DECF TEMP1,F ;update shift counter
|
||
0365 1903 01895 BTFSC STATUS,Z
|
||
0366 2B78 01896 GOTO STUFFRIGHT ;if done, stuff new data
|
||
01897 ;otherwise do nextright...
|
||
0367 01898 NEXTRIGHT
|
||
0367 0384 01899 DECF FSR,F ;if not done, shift across bytes
|
||
0368 0E00 01900 SWAPF INDF,W ; copy high nibble into low nibble and to w
|
||
0369 390F 01901 ANDLW B'00001111' ;get nibble to be shifted...
|
||
036A 0A84 01902 INCF FSR,F ;access 'current' location again
|
||
036B 0480 01903 IORWF INDF,F ;replace with shifted data.
|
||
036C 0384 01904 DECF FSR,F ;point to next byte!
|
||
036D 0390 01905 DECF TEMP1,F ;update shift counter
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 38
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
036E 1903 01906 BTFSC STATUS,Z
|
||
036F 2B71 01907 GOTO STUFFLEFT ;if done, stuff new data
|
||
0370 2B60 01908 GOTO NEXTLEFT
|
||
01909
|
||
0371 01910 STUFFLEFT
|
||
0371 0800 01911 MOVF INDF,W ;recover current byte
|
||
0372 390F 01912 ANDLW B'00001111' ;clear left nibble
|
||
0373 0080 01913 MOVWF INDF ;replace byte
|
||
0374 0E17 01914 SWAPF WLCDTEMP,W ;move replacement nibble into position
|
||
0375 39F0 01915 ANDLW B'11110000' ;just replace left nibble
|
||
0376 0480 01916 IORWF INDF,F ;done!
|
||
0377 0008 01917 RETURN
|
||
01918
|
||
0378 01919 STUFFRIGHT
|
||
0378 0800 01920 MOVF INDF,W ;recover current byte
|
||
0379 39F0 01921 ANDLW B'11110000' ;clear right nibble
|
||
037A 0080 01922 MOVWF INDF ;replace byte
|
||
037B 0817 01923 MOVF WLCDTEMP,W
|
||
037C 390F 01924 ANDLW B'00001111' ;just replace right nibble
|
||
037D 0480 01925 IORWF INDF,F ;done!
|
||
037E 0008 01926 RETURN
|
||
01927
|
||
01928 ;a whole bunch of lcd routines to make life easier
|
||
01929
|
||
037F 01930 INITWLCD
|
||
037F 23EE 01931 CALL WMILLISECS ;wait w ms (may be power up condition)
|
||
0380 3030 01932 MOVLW B'00110000'
|
||
0381 39F0 01933 ANDLW B'11110000' ;just high bits first
|
||
0382 0098 01934 MOVWF NIBBLES ;save high nibbles
|
||
0383 0816 01935 MOVF SHADOWB,W ;get control bits from flags
|
||
0384 390F 01936 ANDLW B'00001111' ; they are in lower 4 bits
|
||
0385 0418 01937 IORWF NIBBLES,W ;save result in w
|
||
0386 0086 01938 MOVWF PORTB ;output high bits and controls...
|
||
0387 1506 01939 BSF PORTB,LCDE ;begin enable strobe...
|
||
0388 0000 01940 NOP ;add extra 1 us delay
|
||
0389 1106 01941 BCF PORTB,LCDE ;end enable strobe
|
||
038A 0008 01942 RETURN
|
||
01943
|
||
038B 01944 LCDRESET
|
||
038B 3010 01945 MOVLW D'16'
|
||
038C 237F 01946 CALL INITWLCD ;wait 16 ms (may be power up condition)
|
||
01947 ;do lcd song and dance init thing
|
||
01948
|
||
038D 3001 01949 MOVLW D'1'
|
||
038E 237F 01950 CALL INITWLCD ;wait 1 ms (may be power up condition)
|
||
01951 ;do lcd song and dance init thing
|
||
01952
|
||
01953 ;most data sheets show 3 initializations,
|
||
01954 ;but I have always found 2 to be enough.
|
||
01955
|
||
038F 3001 01956 MOVLW D'1'
|
||
0390 23EE 01957 CALL WMILLISECS ;wait 1 ms (we don't read busy flag)
|
||
0391 3020 01958 MOVLW B'00100000'
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 39
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
0392 39F0 01959 ANDLW B'11110000' ;just high bits first
|
||
0393 0098 01960 MOVWF NIBBLES ;save high nibbles
|
||
0394 0816 01961 MOVF SHADOWB,W ;get control bits from flags
|
||
0395 390F 01962 ANDLW B'00001111' ; they are in lower 4 bits
|
||
0396 0418 01963 IORWF NIBBLES,W ;save result in w
|
||
0397 0086 01964 MOVWF PORTB ;set for 4 bit mode
|
||
0398 1506 01965 BSF PORTB,LCDE ;begin enable strobe...
|
||
0399 0000 01966 NOP ;add extra 1 us delay for good luck
|
||
039A 1106 01967 BCF PORTB,LCDE ;end enable strobe
|
||
01968
|
||
039B 3001 01969 MOVLW D'1'
|
||
039C 23EE 01970 CALL WMILLISECS ;wait 1 ms to allow it to take
|
||
01971
|
||
01972 ;from here on out we use 4 bit interface!
|
||
01973 ;proper delays are built-in.
|
||
01974
|
||
039D 3028 01975 MOVLW B'00101000' ;set 4 bit, 2 lines, 5x7 font
|
||
039E 23BF 01976 CALL LCDCOMMAND
|
||
01977
|
||
039F 300C 01978 MOVLW B'00001100' ;display on, cursor off,blink off
|
||
03A0 23BF 01979 CALL LCDCOMMAND
|
||
01980
|
||
03A1 23A5 01981 CALL LCDCLEAR ;clear lcd
|
||
01982
|
||
03A2 3006 01983 MOVLW B'00000110' ;increment cursor and no display shift
|
||
03A3 23BF 01984 CALL LCDCOMMAND
|
||
03A4 0008 01985 RETURN
|
||
01986
|
||
01987 ;lcd commands: called subroutines. each clobbers w.
|
||
01988
|
||
03A5 01989 LCDCLEAR
|
||
03A5 3001 01990 MOVLW B'00000001'
|
||
03A6 2BBF 01991 GOTO LCDCOMMAND
|
||
01992
|
||
03A7 23AD 01993 LCDCLEAR1 CALL LCDHOME1
|
||
03A8 23B3 01994 CALL LCDLINECLEAR
|
||
03A9 2BAD 01995 GOTO LCDHOME1
|
||
01996
|
||
03AA 23B1 01997 LCDCLEAR2 CALL LCDHOME2
|
||
03AB 23B3 01998 CALL LCDLINECLEAR
|
||
03AC 2BB1 01999 GOTO LCDHOME2
|
||
02000
|
||
03AD 02001 LCDHOME1
|
||
03AD 3002 02002 MOVLW B'00000010' ;home to line 1 and set display to normal
|
||
03AE 2BBF 02003 GOTO LCDCOMMAND
|
||
02004
|
||
03AF 02005 LCDADDRESS
|
||
03AF 3880 02006 IORLW B'10000000' ;append command to address in w.
|
||
03B0 2BBF 02007 GOTO LCDCOMMAND ; sets ddram address.
|
||
02008
|
||
03B1 30C0 02009 LCDHOME2 MOVLW B'11000000' ;set ddram address to h'40'
|
||
03B2 2BBF 02010 GOTO LCDCOMMAND ; which is line 2
|
||
02011
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 40
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
03B3 3010 02012 LCDLINECLEAR MOVLW D'16' ;lines are 16 characters long
|
||
03B4 0090 02013 MOVWF TEMP1
|
||
03B5 3020 02014 LLCLOOP MOVLW ' ' ;clear by writing 16 spaces
|
||
03B6 23BC 02015 CALL LCDOUT
|
||
03B7 0390 02016 DECF TEMP1,F ;update loop count and w
|
||
03B8 0890 02017 MOVF TEMP1,F
|
||
03B9 1D03 02018 BTFSS STATUS,Z
|
||
03BA 2BB5 02019 GOTO LLCLOOP
|
||
03BB 0008 02020 RETURN
|
||
02021
|
||
02022 ;lcdout: called subroutine. w contains data to be sent in two 4 bit nibbles.
|
||
02023 ;includes delay since we do not read the busy flag. w unaffected.
|
||
02024
|
||
03BC 02025 LCDOUT
|
||
03BC 1596 02026 BSF SHADOWB,LCDRS ;set data mode in flags register
|
||
03BD 23C5 02027 CALL LCDNIBBLES ;do common lcd routine
|
||
03BE 0008 02028 RETURN
|
||
02029
|
||
02030
|
||
02031
|
||
02032
|
||
02033 ;lcdcommand: called subroutine. w contains data to be sent in two 4 bit nibbles.
|
||
02034 ;includes delay since we do not read the busy flag. w not affected.
|
||
02035
|
||
03BF 02036 LCDCOMMAND
|
||
03BF 1196 02037 BCF SHADOWB,LCDRS ;set instruction mode in flags register
|
||
03C0 23C5 02038 CALL LCDNIBBLES ;do common lcd routine
|
||
03C1 3004 02039 MOVLW D'4'
|
||
03C2 23EE 02040 CALL WMILLISECS ;wait another 4 ms (we don't read busy flag)
|
||
03C3 0817 02041 MOVF WLCDTEMP,W ;we have w back!
|
||
03C4 0008 02042 RETURN
|
||
02043
|
||
02044 ;NOTE! lcdnibbles is the low-level interface between data to be displayed and
|
||
02045 ; the actual hardware implementation of the 4 data bits and control stuff.
|
||
02046 ; if you implement a different port useage, then this routine would have to
|
||
02047 ; be modified. pay special attention to the necessary bit masks and port used!
|
||
02048
|
||
03C5 02049 LCDNIBBLES
|
||
03C5 0097 02050 MOVWF WLCDTEMP ;save w!
|
||
03C6 3001 02051 MOVLW D'1'
|
||
03C7 23E3 02052 CALL _200USECS ;wait min. .2 ms (we don't read busy flag)
|
||
03C8 1116 02053 BCF SHADOWB,LCDE ;set e strobe low (default)
|
||
03C9 0817 02054 MOVF WLCDTEMP,W ;recover original
|
||
03CA 39F0 02055 ANDLW B'11110000' ;just high bits first
|
||
03CB 0098 02056 MOVWF NIBBLES ;save high nibbles
|
||
03CC 0816 02057 MOVF SHADOWB,W ;get control bits from flags
|
||
03CD 390F 02058 ANDLW B'00001111' ; they are in lower 4 bits
|
||
03CE 0418 02059 IORWF NIBBLES,W ;save result in w
|
||
03CF 0086 02060 MOVWF PORTB ;output high bits and controls...
|
||
03D0 1506 02061 BSF PORTB,LCDE ;begin enable strobe...
|
||
03D1 0000 02062 NOP ;add extra 1 us delay
|
||
03D2 1106 02063 BCF PORTB,LCDE ;end enable strobe
|
||
02064
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 41
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
03D3 0E97 02065 SWAPF WLCDTEMP,F ;swap hi and lo nibbles of original
|
||
02066 ;(leave lcdrs bit set as-is)
|
||
02067
|
||
03D4 0817 02068 MOVF WLCDTEMP,W ;recover swapped nibble
|
||
03D5 39F0 02069 ANDLW B'11110000' ;now low bits are in high bits
|
||
02070
|
||
03D6 0098 02071 MOVWF NIBBLES ;save this nibble (which was low bits)
|
||
03D7 0816 02072 MOVF SHADOWB,W ;get control bits from flags
|
||
03D8 390F 02073 ANDLW B'00001111' ; they are in lower 4 bits
|
||
03D9 0418 02074 IORWF NIBBLES,W ;save result in w
|
||
03DA 0086 02075 MOVWF PORTB ;output low bits...
|
||
03DB 1506 02076 BSF PORTB,LCDE ;begin enable strobe...
|
||
03DC 0000 02077 NOP ;slight delay
|
||
03DD 1106 02078 BCF PORTB,LCDE ;strobe e goes low now
|
||
02079
|
||
03DE 1596 02080 BSF SHADOWB,LCDRS ;default in flags is data mode
|
||
03DF 1116 02081 BCF SHADOWB,LCDE ;default in flags is strobe enable low
|
||
03E0 0E97 02082 SWAPF WLCDTEMP,F ;back to normal...
|
||
03E1 0817 02083 MOVF WLCDTEMP,W ;we have w back!
|
||
03E2 0008 02084 RETURN
|
||
02085
|
||
02086
|
||
02087 ;==============================================================================
|
||
02088 ; _200usecs: (subroutine) : 200 usec delay.
|
||
02089 ;==============================================================================
|
||
02090
|
||
02091
|
||
03E3 02092 _200USECS
|
||
03E3 3041 02093 MOVLW (D'200'-3)/3 ;number of loops
|
||
03E4 0093 02094 MOVWF XMILLISEC ;(shared register)
|
||
03E5 02095 _200LOOP
|
||
03E5 0393 02096 DECF XMILLISEC,F ;count down
|
||
03E6 1D03 02097 BTFSS STATUS,Z
|
||
03E7 2BE5 02098 GOTO _200LOOP
|
||
03E8 0008 02099 RETURN
|
||
02100
|
||
03E9 02101 DELAY1000
|
||
03E9 23ED 02102 CALL XMILLISECS
|
||
03EA 02103 DELAY800
|
||
03EA 23ED 02104 CALL XMILLISECS
|
||
03EB 02105 DELAY600
|
||
03EB 23ED 02106 CALL XMILLISECS
|
||
03EC 02107 DELAY400
|
||
03EC 23ED 02108 CALL XMILLISECS
|
||
02109 ;flow into xmillisecs for last 200 ms delay
|
||
02110 ;==============================================================================
|
||
02111 ; xmillisecs: (subroutine) : 200 msec delay. flows into wmillisec.
|
||
02112 ;==============================================================================
|
||
02113
|
||
03ED 02114 XMILLISECS
|
||
03ED 30C8 02115 MOVLW D'200' ;delay...
|
||
02116
|
||
02117 ;==============================================================================
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 42
|
||
|
||
|
||
LOC OBJECT CODE LINE SOURCE TEXT
|
||
VALUE
|
||
|
||
02118 ; wmillisecs: (subroutine) : delay for w millisecs. tuned for 4.00 mhz xtal.
|
||
02119 ;==============================================================================
|
||
02120
|
||
02121 ;called subroutine set to generate delays.
|
||
02122 ;enter with # of milliseconds to delay in W
|
||
02123
|
||
03EE 02124 WMILLISECS
|
||
02125
|
||
03EE 0093 02126 MOVWF XMILLISEC ;save # of millisecs in w to delay.
|
||
02127
|
||
03EF 0A93 02128 INCF XMILLISEC,F ;adjust to account for initial decrement.
|
||
02129 ;first (outer) loop.
|
||
02130
|
||
03F0 02131 WMLOOP1
|
||
03F0 0B93 02132 DECFSZ XMILLISEC,F ;update first (outer) loop
|
||
03F1 2BF3 02133 GOTO WMLOOPA ;if more to do, do it.
|
||
02134
|
||
03F2 0008 02135 RETURN ;done when xmillisec=0.
|
||
02136
|
||
03F3 02137 WMLOOPA
|
||
03F3 0194 02138 CLRF YMILLISEC ;second (inner) loop
|
||
02139 ;256 loops (256+1 becomes 0)
|
||
02140
|
||
03F4 02141 WMLOOPB
|
||
03F4 0B94 02142 DECFSZ YMILLISEC,F ;update 256 part of inner loop.
|
||
03F5 2BF4 02143 GOTO WMLOOPB ;3 usec per loop
|
||
02144
|
||
03F6 304C 02145 MOVLW D'75'+1
|
||
03F7 0094 02146 MOVWF YMILLISEC ;75 loops for third loop
|
||
02147
|
||
03F8 02148 WMLOOPC
|
||
03F8 0B94 02149 DECFSZ YMILLISEC,F ;update 75 part of inner loop.
|
||
03F9 2BF8 02150 GOTO WMLOOPC ;3 usec per loop
|
||
02151
|
||
03FA 2BF0 02152 GOTO WMLOOP1 ;continue with next outer loop
|
||
02153
|
||
02154 ;total for inner loop sets is
|
||
02155 ;3*(256+75)=993 usec.
|
||
02156 ;this together with the overhead
|
||
02157 ;makes the total as close to 1000 usec
|
||
02158 ;as we need.
|
||
02159 ;1000 usec = 1 millisecond
|
||
02160 ;hey, it's good enough for *me*!
|
||
02161
|
||
02162 ;==============================================================================
|
||
02163 ; end of program (at last! Now I can finally get some much needed sleep!!)
|
||
02164 ;==============================================================================
|
||
02165
|
||
02166 END
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 43
|
||
|
||
|
||
SYMBOL TABLE
|
||
LABEL VALUE
|
||
|
||
ACOPY 00000015
|
||
ADDTENS 00000300
|
||
ADDTENS10 000002FC
|
||
ADDTENSX0 000002FD
|
||
ADDTENSXX 000002FF
|
||
AUTOFLAGS 00000022
|
||
AUTOTEXT 00000055
|
||
BB0 00000151
|
||
BB0NEG 00000157
|
||
BB1 0000015D
|
||
BB1NEG 00000163
|
||
BB2 00000164
|
||
BEGIN1TEXT 00000038
|
||
BEGIN2TEXT 00000046
|
||
BIN24BIGGER 00000150
|
||
BIN24_0 00000023
|
||
BIN24_1 00000024
|
||
BIN24_2 00000025
|
||
BIN2DEC 00000191
|
||
BIN2DECDONE 000001C3
|
||
BYTE0 00000191
|
||
BYTE0LOOP 00000195
|
||
BYTE1 00000199
|
||
BYTE1LOOP 0000019D
|
||
BYTE2 000001AA
|
||
BYTE2LOOP 000001AE
|
||
C 00000000
|
||
CHECK2LOW 000001EB
|
||
CHECK3LOW 00000208
|
||
CHECK4LOW 0000021C
|
||
CHECKHIT 000000D3
|
||
CLEARALLDATA 000002ED
|
||
CLEARLOOP 000002EF
|
||
CLOCK 000F4240
|
||
COMMONA 00000233
|
||
COMMONSTAR 00000234
|
||
COMMONSTUFF 00000225
|
||
COMMONSTUFFR 00000224
|
||
COMMONTEXT 00000066
|
||
CONTROLA 00000000
|
||
CONTROLB 00000001
|
||
CONVERT 00000025
|
||
CONVERTIT 00000186
|
||
COPYZERO 00000186
|
||
DATALOOP 00000340
|
||
DATAOUT 0000033B
|
||
DB4 00000004
|
||
DB5 00000005
|
||
DB6 00000006
|
||
DB7 00000007
|
||
DC 00000001
|
||
DELAY1000 000003E9
|
||
DELAY400 000003EC
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 44
|
||
|
||
|
||
SYMBOL TABLE
|
||
LABEL VALUE
|
||
|
||
DELAY600 000003EB
|
||
DELAY800 000003EA
|
||
DOWNKEY 00000003
|
||
DOWNTO1 000000FC
|
||
DOWNTO2 000000F6
|
||
DOWNTO3 000000F4
|
||
DROP 00000017
|
||
EEADR 00000009
|
||
EECON1 00000088
|
||
EECON2 00000089
|
||
EEDATA 00000008
|
||
EEIE 00000006
|
||
EEIF 00000004
|
||
EQUAL_0 0000014C
|
||
EQUAL_1 00000147
|
||
EQUAL_2 00000142
|
||
EVEN 00000312
|
||
EVENSTUFF 0000030C
|
||
EXAMPLE 00002100
|
||
EXPONENT 00000012
|
||
F 00000001
|
||
FLAGS 00000021
|
||
FLIP 000002DE
|
||
FLIPCHAR 00000020
|
||
FLIPFLOP 00000005
|
||
FLOP 000002E4
|
||
FLOPCHAR 000000FF
|
||
FOURPLUS 00000247
|
||
FOURSPACES 0000007E
|
||
FSR 00000004
|
||
GETHIT 000000CC
|
||
GIE 00000007
|
||
GOTIT 00000003
|
||
GOTITYET 000002E9
|
||
GOTSYNC 000002D1
|
||
HITDONE 00000100
|
||
IND0 00000000
|
||
INDF 00000000
|
||
INITWLCD 0000037F
|
||
INTCON 0000000B
|
||
INTE 00000004
|
||
INTEDG 00000006
|
||
INTF 00000001
|
||
INTFINISH 0000001E
|
||
INTHANDLER 00000004
|
||
INTOVERFLOW 00000000
|
||
INTPERIOD 00000016
|
||
INTRETURN 00000018
|
||
INTTMR0 0000000D
|
||
IRP 00000007
|
||
ISIT2 000001D6
|
||
ISIT3 000001F4
|
||
ISITDOWN 000000EE
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 45
|
||
|
||
|
||
SYMBOL TABLE
|
||
LABEL VALUE
|
||
|
||
ISZERO 000000FE
|
||
ITS1 000001C7
|
||
ITS2 000001DA
|
||
ITS3 000001F8
|
||
ITS4 00000211
|
||
ITWAS2 000000EA
|
||
ITWASDOWN 000000F0
|
||
ITWASUP 000000E0
|
||
LCDADDRESS 000003AF
|
||
LCDCLEAR 000003A5
|
||
LCDCLEAR1 000003A7
|
||
LCDCLEAR2 000003AA
|
||
LCDCOMMAND 000003BF
|
||
LCDE 00000002
|
||
LCDHOME1 000003AD
|
||
LCDHOME2 000003B1
|
||
LCDLINECLEAR 000003B3
|
||
LCDNIBBLES 000003C5
|
||
LCDOUT 000003BC
|
||
LCDRESET 0000038B
|
||
LCDRS 00000003
|
||
LEFTCHECK 0000025A
|
||
LLCLOOP 000003B5
|
||
MAINLOOP 000000C3
|
||
MAINPROG 000000B0
|
||
MANTISSA 0000000F
|
||
MANUAL 00000000
|
||
MANUAL2TEXT 00000072
|
||
MSTUFF 00000242
|
||
MU 000000E4
|
||
N0 00000000
|
||
N1 00000001
|
||
N2 00000002
|
||
N3 00000003
|
||
N4 00000004
|
||
N5 00000005
|
||
N6 00000006
|
||
N7 00000007
|
||
N8 00000008
|
||
N9 00000009
|
||
NCOMMA 0000000D
|
||
NEXTLEFT 00000360
|
||
NEXTRIGHT 00000367
|
||
NIBBLES 00000018
|
||
NMINUS 0000000C
|
||
NOTEQUAL 0000013F
|
||
NOT_PD 00000003
|
||
NOT_RBPU 00000007
|
||
NOT_TO 00000004
|
||
NPERIOD 0000000E
|
||
NPLUS 0000000B
|
||
NSPACE 0000000A
|
||
NX 0000000F
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 46
|
||
|
||
|
||
SYMBOL TABLE
|
||
LABEL VALUE
|
||
|
||
ODD 0000032E
|
||
ODDSTUFF 0000030F
|
||
OFFSET1_0 0000002A
|
||
OFFSET1_1 0000002B
|
||
OFFSET1_2 0000002C
|
||
OFFSET2_0 0000002D
|
||
OFFSET2_1 0000002E
|
||
OFFSET2_2 0000002F
|
||
OFFSET3_0 00000030
|
||
OFFSET3_1 00000031
|
||
OFFSET3_2 00000032
|
||
OFFSET4_0 00000033
|
||
OFFSET4_1 00000034
|
||
OFFSET4_2 00000035
|
||
OFFSETBIGGER 00000167
|
||
OFFSETX 00000026
|
||
OFFSET_0 00000027
|
||
OFFSET_1 00000028
|
||
OFFSET_2 00000029
|
||
OLDHIT 000000D9
|
||
OPTION_REG 00000081
|
||
OVERFLOWED 000000C8
|
||
OVERTEXT 00000066
|
||
OVER_0 00000036
|
||
OVER_1 00000037
|
||
OVER_2 00000038
|
||
PCL 00000002
|
||
PCLATH 0000000A
|
||
PD 00000003
|
||
PERIODIN 00000000
|
||
PERIODINIT 00000277
|
||
PERIODINIT2 00000284
|
||
PLUSMINUS 00000004
|
||
PORTA 00000005
|
||
PORTB 00000006
|
||
PROCESSDATA 000000C5
|
||
PS0 00000000
|
||
PS1 00000001
|
||
PS2 00000002
|
||
PSA 00000003
|
||
PSELECT 00000001
|
||
RANGECHANGE 00000002
|
||
RBIE 00000003
|
||
RBIF 00000000
|
||
RBPU 00000007
|
||
RD 00000000
|
||
RIGHTCHECK 00000271
|
||
RP0 00000005
|
||
RP1 00000006
|
||
RTCC 00000001
|
||
RTE 00000004
|
||
RTIE 00000005
|
||
RTIF 00000002
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 47
|
||
|
||
|
||
SYMBOL TABLE
|
||
LABEL VALUE
|
||
|
||
RTS 00000005
|
||
SAVEFSR 0000000E
|
||
SAVESTATUS 0000000D
|
||
SAVEW 0000000C
|
||
SD 0000035A
|
||
SD12P 00000353
|
||
SD12S 0000034F
|
||
SD15X 00000357
|
||
SD4C 0000034B
|
||
SDXC 0000034C
|
||
SDXP 00000354
|
||
SET1 0000010C
|
||
SET1_2 00000111
|
||
SET2 00000116
|
||
SET3 0000011C
|
||
SET4 00000126
|
||
SETEVENNEGATIVE 0000031B
|
||
SETEVENPOSITIVE 00000326
|
||
SETEVENZERO 00000321
|
||
SETSTUFF 00000108
|
||
SETUP 0000009E
|
||
SETZEROX 00000130
|
||
SHADOWB 00000016
|
||
SHIFT 00000010
|
||
SHIFTANDDROP 0000035A
|
||
SOMETEXT 00000037
|
||
SPACEIT 0000026B
|
||
START 00000000
|
||
STARTTEXT 00000038
|
||
STATUS 00000003
|
||
STOP 00000001
|
||
STUFFLEFT 00000371
|
||
STUFFRIGHT 00000378
|
||
SUBTRACTOFFSET 0000013B
|
||
SYNC1 00000289
|
||
SYNC2 000002AD
|
||
SYNCONHIGH1 0000028E
|
||
SYNCONHIGH1B 0000029B
|
||
SYNCONHIGH2 000002C1
|
||
SYNCONHIGH2B 000002CE
|
||
SYNCONLOW1 0000029D
|
||
SYNCONLOW1B 000002AA
|
||
SYNCONLOW2 000002B2
|
||
SYNCONLOW2B 000002BF
|
||
T0CS 00000005
|
||
T0IE 00000005
|
||
T0IF 00000002
|
||
T0SE 00000004
|
||
TEMP0 0000000F
|
||
TEMP1 00000010
|
||
TEMP2 00000011
|
||
TEMP3 00000012
|
||
TEXTLOOP 00000333
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 48
|
||
|
||
|
||
SYMBOL TABLE
|
||
LABEL VALUE
|
||
|
||
TEXTOUT 00000332
|
||
TMR0 00000001
|
||
TO 00000004
|
||
TOOLONG 00000003
|
||
TRISA 00000085
|
||
TRISB 00000086
|
||
UFNFPFTEXT 00000082
|
||
UPKEY 00000004
|
||
UPTO2 000000E4
|
||
UPTO3 000000E6
|
||
UPTO4 000000EC
|
||
USUAL 00000249
|
||
W 00000000
|
||
WAITLOOP 000002D9
|
||
WLCDTEMP 00000017
|
||
WMILLISECS 000003EE
|
||
WMLOOP1 000003F0
|
||
WMLOOPA 000003F3
|
||
WMLOOPB 000003F4
|
||
WMLOOPC 000003F8
|
||
WR 00000001
|
||
WREN 00000002
|
||
WRERR 00000003
|
||
X10 00000019
|
||
X32 0000001A
|
||
X54 0000001B
|
||
X76 0000001C
|
||
X98 0000001D
|
||
XBA 0000001E
|
||
XDC 0000001F
|
||
XFE 00000020
|
||
XLSB 00000019
|
||
XMILLISEC 00000013
|
||
XMILLISECS 000003ED
|
||
XMSB 00000020
|
||
XTAL_FREQ 003D0900
|
||
YMILLISEC 00000014
|
||
Z 00000002
|
||
ZEROKEY 00000002
|
||
ZEROLOOP 0000024E
|
||
ZEROOFF 0000024B
|
||
ZEROTEXT 0000008E
|
||
_200LOOP 000003E5
|
||
_200USECS 000003E3
|
||
_CP_OFF 00003FFF
|
||
_CP_ON 0000000F
|
||
_HS_OSC 00003FFE
|
||
_LP_OSC 00003FFC
|
||
_PWRTE_OFF 00003FFF
|
||
_PWRTE_ON 00003FF7
|
||
_RC_OSC 00003FFF
|
||
_WDT_OFF 00003FFB
|
||
_WDT_ON 00003FFF
|
||
MPASM 02.30.11 Intermediate CMETERA.ASM 10-7-2000 22:08:08 PAGE 49
|
||
|
||
|
||
SYMBOL TABLE
|
||
LABEL VALUE
|
||
|
||
_XT_OSC 00003FFD
|
||
__16F84 00000001
|
||
|
||
|
||
MEMORY USAGE MAP ('X' = Used, '-' = Unused)
|
||
|
||
0000 : X---XXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0040 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0080 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
00C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0140 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0180 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
01C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0200 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0240 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0280 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
02C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0300 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0340 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
0380 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX
|
||
03C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXX-----
|
||
2000 : -------X-------- ---------------- ---------------- ----------------
|
||
2100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXX---------
|
||
|
||
All other memory blocks unused.
|
||
|
||
Program Memory Words Used: 1016
|
||
Program Memory Words Free: 8
|
||
|
||
|
||
Errors : 0
|
||
Warnings : 0 reported, 0 suppressed
|
||
Messages : 12 reported, 0 suppressed
|
||
|
||
|