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