MPASM 03.70.01 Released BIN4.ASM 2-28-2006 17:22:20 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00002 ; 00003 ; Source File: BIN4.ASM 00004 ; Author: MPB 00005 ; Date: 28-5-05 00006 ; 00007 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00008 ; 00009 ; Slow output binary count is stopped, started 00010 ; and reset with push buttons. 00011 ; 00012 ; Processor: PIC 16F877 00013 ; 00014 ; Hardware: PIC Demo System 00015 ; Clock: RC = 100kHz 00016 ; Inputs: Port D: Push Buttons 00017 ; RD0, RD1 (active low) 00018 ; Outputs: Port B: LEDs (active high) 00019 ; 00020 ; WDTimer: Disabled 00021 ; PUTimer: Enabled 00022 ; Interrupts: Disabled 00023 ; Code Protect: Disabled 00024 ; 00025 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00026 00027 PROCESSOR 16F877 ; Define MCU type 2007 3733 00028 __CONFIG 0x3733 ; Set config fuses 00029 00030 ; Register Label Equates.................................... 00031 00000006 00032 PORTB EQU 06 ; Port B Data Register 00000086 00033 TRISB EQU 86 ; Port B Direction Register 00000008 00034 PORTD EQU 08 ; Port D Data Register 00000020 00035 Timer EQU 20 ; GPR used as delay counter 00036 00037 ; Input Bit Label Equates .................................. 00038 00000000 00039 Inres EQU 0 ; 'Reset' input button = RD0 00000001 00040 Inrun EQU 1 ; 'Run' input button = RD1 00041 00042 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00043 00044 ; Initialise Port B (Port A defaults to inputs)............. 00045 0000 1683 1303 00046 BANKSEL TRISB ; Select bank 1 0002 3000 00047 MOVLW b'00000000' ; Port B Direction Code Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0003 0086 00048 MOVWF TRISB ; Load the DDR code into F86 0004 1283 1303 00049 BANKSEL PORTB ; Select bank 0 0006 280B 00050 GOTO reset ; Jump to main loop 00051 00052 MPASM 03.70.01 Released BIN4.ASM 2-28-2006 17:22:20 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00053 ; 'delay' subroutine ........................................ 00054 0007 00A0 00055 delay MOVWF Timer ; Copy W to timer register Message[305]: Using default destination of 1 (file). 0008 0BA0 00056 down DECFSZ Timer ; Decrement timer register 0009 2808 00057 GOTO down ; and repeat until zero 000A 0008 00058 RETURN ; Jump back to main program 00059 00060 00061 ; Start main loop ........................................... 00062 000B 0186 00063 reset CLRF PORTB ; Clear Port B Data 00064 000C 1C08 00065 start BTFSS PORTD,Inres ; Test reset button 000D 280B 00066 GOTO reset ; and reset Port B if pressed 000E 1888 00067 BTFSC PORTD,Inrun ; Test run button 000F 280C 00068 GOTO start ; and repeat if n pressed 00069 Message[305]: Using default destination of 1 (file). 0010 0A86 00070 INCF PORTB ; Increment output at Port B 0011 30FF 00071 MOVLW 0FF ; Delay count literal 0012 2007 00072 CALL delay ; Jump to subroutine 'delay' 0013 280C 00073 GOTO start ; Repeat main loop always 00074 00075 END ; Terminate source code MPASM 03.70.01 Released BIN4.ASM 2-28-2006 17:22:20 PAGE 3 SYMBOL TABLE LABEL VALUE Inres 00000000 Inrun 00000001 PORTB 00000006 PORTD 00000008 TRISB 00000086 Timer 00000020 __16F877 00000001 delay 00000007 down 00000008 reset 0000000B start 0000000C MEMORY USAGE MAP ('X' = Used, '-' = Unused) 0000 : XXXXXXXXXXXXXXXX XXXX------------ ---------------- ---------------- 2000 : -------X-------- ---------------- ---------------- ---------------- All other memory blocks unused. Program Memory Words Used: 20 Program Memory Words Free: 8172 Errors : 0 Warnings : 0 reported, 0 suppressed Messages : 3 reported, 0 suppressed