MPASM 03.70.01 Released LED1S.ASM 2-28-2006 19:49:33 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00002 ; 00003 ; Source File: LED1S.ASM 00004 ; Author: MPB 00005 ; Date: 2-12-05 00006 ; 00007 ; Output binary count is stepped manually 00008 ; and reset with push buttons. 00009 ; Demonstrates software delay switch debounce 00010 ; 00011 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00012 00013 PROCESSOR 16F877 ; Define MCU type 2007 3733 00014 __CONFIG 0x3733 ; Set config fuses 00015 00016 ; Register Label Equates.................................... 00017 00000006 00018 PORTB EQU 06 ; Port B Data Register 00000008 00019 PORTD EQU 08 ; Port D Data Register 00000088 00020 TRISD EQU 88 ; Port B Direction Register 00000020 00021 Timer EQU 20 ; GPR used as delay counter 00022 00023 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00024 00025 ; Initialise Port B (Port A defaults to inputs)............. 00026 0000 1683 1303 00027 BANKSEL TRISD ; Select bank 1 0002 3000 00028 MOVLW b'00000000' ; Port B Direction Code Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0003 0088 00029 MOVWF TRISD ; Load the DDR code into F86 0004 1283 1303 00030 BANKSEL PORTD ; Select bank 0 0006 280B 00031 GOTO reset ; Jump to main loop 00032 00033 ; 'delay' subroutine ........................................ 00034 0007 00A0 00035 delay MOVWF Timer ; Copy W to timer register Message[305]: Using default destination of 1 (file). 0008 0BA0 00036 down DECFSZ Timer ; Decrement timer register 0009 2808 00037 GOTO down ; and repeat until zero 000A 0008 00038 RETURN ; Jump back to main program 00039 00040 ; Start main loop ........................................... 00041 000B 0188 00042 reset CLRF PORTD ; Clear LEDs 00043 000C 1C86 00044 start BTFSS PORTB,1 ; Test reset button 000D 280B 00045 GOTO reset ; and clear LEDs 000E 1906 00046 BTFSC PORTB,2 ; Test step button 000F 280C 00047 GOTO start ; and repeat if not pressed 00048 0010 30FF 00049 MOVLW 0FF ; Delay count literal 0011 2007 00050 CALL delay ; Wait for count 0012 1D06 00051 BTFSS PORTB,2 ; Test step button MPASM 03.70.01 Released LED1S.ASM 2-28-2006 19:49:33 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0013 280C 00052 GOTO start ; and wait if not released Message[305]: Using default destination of 1 (file). 0014 0A88 00053 INCF PORTD ; Increment LEDs 0015 280C 00054 GOTO start ; Repeat always 00055 00056 END ; Terminate source code MPASM 03.70.01 Released LED1S.ASM 2-28-2006 19:49:33 PAGE 3 SYMBOL TABLE LABEL VALUE PORTB 00000006 PORTD 00000008 TRISD 00000088 Timer 00000020 __16F877 00000001 delay 00000007 down 00000008 reset 0000000B start 0000000C MEMORY USAGE MAP ('X' = Used, '-' = Unused) 0000 : XXXXXXXXXXXXXXXX XXXXXX---------- ---------------- ---------------- 2000 : -------X-------- ---------------- ---------------- ---------------- All other memory blocks unused. Program Memory Words Used: 22 Program Memory Words Free: 8170 Errors : 0 Warnings : 0 reported, 0 suppressed Messages : 3 reported, 0 suppressed