Newer
Older
pic-count / count.lst
MPASM 03.00 Released            COUNT.ASM   3-10-2002  16:22:35         PAGE  1


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

                      00001 ; COUNT.ASM
                      00002 ; Copyright (c) 2002, TundraWare Inc.
                      00003 ; 
                      00004 ; Loosely based on David Tait's LED 'WALK.ASM' Test Program
                      00005 ; Uses same hardware setup but counts in binary, flashing at
                      00006 ; full count.
                      00007 
                      00008 ;;; Generally speaking, UPPER-CASE symbols in the code below are
                      00009 ;;; defined in the standard MPLAB include file.  My code is in
                      00010 ;;; lower-case.
                      00011  
                      00012         
                      00013         list            p=16F84A
                      00014         #include        <P16F84A.INC>
                      00001         LIST
                      00002 ; P16F84A.INC  Standard Header File, Version 2.00    Microchip Technology, Inc.
                      00134         LIST
                      00015 
                      00016         errorlevel      -302    ;suppress bank selection messages
2007   3FF5           00017         __config        3ff5h   ;xt osc, watchdog
2000   0001 0002 0003 00018         __idlocs        1234
       0004 
                      00019  
                      00020 ;;; Device Constants
                      00021          
                      00022 
  00000008            00023 pre1    equ     08h             ; prescaler constants
  00000009            00024 pre2    equ     09h
  0000000A            00025 pre4    equ     0ah
  0000000B            00026 pre8    equ     0bh
  0000000C            00027 pre16   equ     0ch
  0000000D            00028 pre32   equ     0dh
  0000000E            00029 pre64   equ     0eh
  0000000F            00030 pre128  equ     0fh     
                      00031 
                      00032 
                      00033 ;;; Program Constants
                      00034         
  00000005            00035 blinkcnt        equ     05h     ; number of times to blink
  0000000D            00036 bcount          equ     0dh     ; register to hold blink count
  0000000F            00037 maxcnt          equ     0fh     ; maximum count to display
  0000000D            00038 preblink        equ     pre32   ; prescaler value for blinking
  0000000C            00039 precount        equ     pre16   ; prescaler value for counting
                      00040         
                      00041 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00042 
                      00043 ;;;
                      00044 ; Main program logic
                      00045 ;;; 
                      00046 
0000   200E           00047 begin   call    portb_w         ; setup PORTB for writing
0001   300C           00048         movlw   precount        ; set prescaler for slow disply
0002   2012           00049         call    wdt_pre
MPASM 03.00 Released            COUNT.ASM   3-10-2002  16:22:35         PAGE  2


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0003   300F           00050         movlw   maxcnt          ; number of counts
0004   0186           00051         clrf    PORTB           ; all leds off
0005   0063           00052 count   sleep                   ; display current count for a while
0006   0A86           00053         incf    PORTB,F         ; next value to display
0007   0806           00054         movf    PORTB,W         ; see if we're displaying 'maxcnt'
0008   390F           00055         andlw   0fh             ; mask hi nibble - no LEDs there
0009   3A0F           00056         xorlw   maxcnt          ; subtract 'maxcnt' from w
000A   1D03           00057         btfss   STATUS,Z
000B   2805           00058         goto    count           ; nope, continue counting
000C   2016           00059         call    blink
000D   2800           00060         goto begin
                      00061 
                      00062 ;;; End of main logic
                      00063 
                      00064 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                      00065 
                      00066 ;;;
                      00067 ; Supporting Subroutines
                      00068 ;;;
                      00069 
                      00070 ;;;
                      00071 ; Set PORTB To Write
                      00072 ; Returns with Bank 0 selected
                      00073 ;;;
                      00074 
000E   1683           00075 portb_w bsf     STATUS,RP0      ; select register bank 1   
000F   0186           00076         clrf    TRISB           ; set PORTB to all outputs
0010   1283           00077         bcf     STATUS,RP0      ; select register bank 0
0011   0008           00078         return  
                      00079 
                      00080 ;;; End of 'portb_w'
                      00081 
                      00082                 
                      00083 ;;;
                      00084 ; Set the WDT Prescaler
                      00085 ; Value required must be passed in w
                      00086 ; Returns with Bank 0 selected
                      00087 ;;;
                      00088 
0012   1683           00089 wdt_pre bsf     STATUS,RP0      ; select register bank 1
0013   0081           00090         movwf   OPTION_REG
0014   1283           00091         bcf     STATUS,RP0      ; bank0 so PORTB is addressable
0015   0008           00092         return
                      00093 
                      00094 ;;; End of 'wdt_pre'
                      00095 
                      00096 
                      00097 ;;;
                      00098 ; Blink The Lights
                      00099 ;;;
                      00100         
0016   300D           00101 blink   movlw   preblink        ; set prescaler for fast blink
0017   2012           00102         call    wdt_pre
MPASM 03.00 Released            COUNT.ASM   3-10-2002  16:22:35         PAGE  3


LOC  OBJECT CODE     LINE SOURCE TEXT
  VALUE

0018   3005           00103         movlw   blinkcnt        ; number of times to blink
0019   008D           00104         movwf   bcount
001A   0063           00105 bcycle  sleep                   ; display on from caller
001B   0186           00106         clrf    PORTB           ; display off
001C   0063           00107         sleep
001D   0B8D           00108         decfsz  bcount,F        ; if zero, we've done 'blinkcnt' repetitions
001E   2820           00109         goto    again           ; we're not done yet
001F   0008           00110         return                  ; all done
0020   300F           00111 again   movlw   maxcnt          ; blink again - display on
0021   0086           00112         movwf   PORTB
0022   281A           00113         goto    bcycle
                      00114                 
                      00115 ;;; End of 'blink'
                      00116         
                      00117 
                      00118 
                      00119 ;;;
                      00120 ; EEPROM Contents
                      00121 ;;;
                      00122         
2100                  00123         org     2100h
                      00124 ;
2100   0024 0049 0064 00125         DE      "$Id: count.asm,v 1.9 2002/03/10 15:43:56 tundra Exp tundra $"
       003A 0020 0063 
       006F 0075 006E 
       0074 002E 0061 
       0073 006D 002C 
       0076 0020 0031 
       002E 0039 0020 
       0032 0030 0030 
       0032 002F 0030 
       0033 002F 0031 
       0030 0020 0031 
       0035 003A 0034 
       0033 003A 0035 
       0036 0020 0074 
       0075 006E 0064 
       0072 0061 0020 
       0045 007
                      00126         END
MPASM 03.00 Released            COUNT.ASM   3-10-2002  16:22:35         PAGE  4


SYMBOL TABLE
  LABEL                             VALUE 

C                                 00000000
DC                                00000001
EEADR                             00000009
EECON1                            00000088
EECON2                            00000089
EEDATA                            00000008
EEIE                              00000006
EEIF                              00000004
F                                 00000001
FSR                               00000004
GIE                               00000007
INDF                              00000000
INTCON                            0000000B
INTE                              00000004
INTEDG                            00000006
INTF                              00000001
IRP                               00000007
NOT_PD                            00000003
NOT_RBPU                          00000007
NOT_TO                            00000004
OPTION_REG                        00000081
PCL                               00000002
PCLATH                            0000000A
PORTA                             00000005
PORTB                             00000006
PS0                               00000000
PS1                               00000001
PS2                               00000002
PSA                               00000003
RBIE                              00000003
RBIF                              00000000
RD                                00000000
RP0                               00000005
RP1                               00000006
STATUS                            00000003
T0CS                              00000005
T0IE                              00000005
T0IF                              00000002
T0SE                              00000004
TMR0                              00000001
TRISA                             00000085
TRISB                             00000086
W                                 00000000
WR                                00000001
WREN                              00000002
WRERR                             00000003
Z                                 00000002
_CP_OFF                           00003FFF
_CP_ON                            0000000F
_HS_OSC                           00003FFE
_LP_OSC                           00003FFC
_PWRTE_OFF                        00003FFF
_PWRTE_ON                         00003FF7
MPASM 03.00 Released            COUNT.ASM   3-10-2002  16:22:35         PAGE  5


SYMBOL TABLE
  LABEL                             VALUE 

_RC_OSC                           00003FFF
_WDT_OFF                          00003FFB
_WDT_ON                           00003FFF
_XT_OSC                           00003FFD
__16F84A                          00000001
again                             00000020
bcount                            0000000D
bcycle                            0000001A
begin                             00000000
blink                             00000016
blinkcnt                          00000005
count                             00000005
maxcnt                            0000000F
portb_w                           0000000E
pre1                              00000008
pre128                            0000000F
pre16                             0000000C
pre2                              00000009
pre32                             0000000D
pre4                              0000000A
pre64                             0000000E
pre8                              0000000B
preblink                          0000000D
precount                          0000000C
wdt_pre                           00000012


MEMORY USAGE MAP ('X' = Used,  '-' = Unused)

0000 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXX------------- ----------------
2000 : XXXX---X-------- ---------------- ---------------- ----------------
2100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXX----

All other memory blocks unused.

Program Memory Words Used:    35
Program Memory Words Free:   989


Errors   :     0
Warnings :     0 reported,     0 suppressed
Messages :     0 reported,     2 suppressed