1 |
|
2 | ;**********************************************************************
|
3 | ; This file is a basic code template for assembly code generation *
|
4 | ; on the PIC16F887. This file contains the basic code *
|
5 | ; building blocks to build upon. *
|
6 | ; *
|
7 | ; Refer to the MPASM User's Guide for additional information on *
|
8 | ; features of the assembler (Document DS33014). *
|
9 | ; *
|
10 | ; Refer to the respective PIC data sheet for additional *
|
11 | ; information on the instruction set. *
|
12 | ; *
|
13 | ;**********************************************************************
|
14 | ; *
|
15 | ; Filename: xxx.asm *
|
16 | ; Date: *
|
17 | ; File Version: *
|
18 | ; *
|
19 | ; Author: *
|
20 | ; Company: *
|
21 | ; *
|
22 | ; *
|
23 | ;**********************************************************************
|
24 | ; *
|
25 | ; Files Required: P16F887.INC *
|
26 | ; *
|
27 | ;**********************************************************************
|
28 | ; *
|
29 | ; Notes: *
|
30 | ; *
|
31 | ;**********************************************************************
|
32 |
|
33 |
|
34 | list p=16f887 ; list directive to define processor
|
35 | #include <p16f887.inc> ; processor specific variable definitions
|
36 |
|
37 |
|
38 | __CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC
|
39 | __CONFIG _CONFIG2, _WRT_OFF & _BOR40V
|
40 |
|
41 |
|
42 | Zaehler1 equ 0x20
|
43 | Zaehler2 equ 0x21
|
44 | Zaehler3 equ 0x22
|
45 |
|
46 | ORG 0x00 ;Power On Reset Startadresse
|
47 |
|
48 | INIT
|
49 |
|
50 |
|
51 | BSF STATUS,RP1 ;Bank 2
|
52 | BCF CM1CON0,C1ON ;Comparator 1 ist aus
|
53 | BCF CM2CON0,C2ON ;Comparator 2 ist aus
|
54 |
|
55 | BANKSEL PORTA
|
56 | CLRF PORTA ;Init PORTA
|
57 | BANKSEL ANSEL
|
58 | CLRF ANSEL ;digital I/O
|
59 | BANKSEL TRISA
|
60 | MOVLW B'00000010' ;alle als Inputs
|
61 | MOVWF TRISA
|
62 |
|
63 | BCF STATUS,RP0 ;Bank 2
|
64 | BCF STATUS,RP1 ;Bank 0
|
65 |
|
66 | CLRF PORTB ;Init PORTB
|
67 | BSF STATUS,RP0 ;Bank 1
|
68 | BSF STATUS,RP1 ;Bank 3
|
69 | CLRF ANSELH ;digital I/O
|
70 | BCF STATUS,RP1
|
71 |
|
72 | MOVLW B'00000000' ;Alle als Output
|
73 | MOVWF TRISB
|
74 | BCF STATUS,RP0 ;Bank 0
|
75 |
|
76 |
|
77 | HAUPTSCHLEIFE
|
78 |
|
79 | CALL Pause
|
80 | CLRF PORTB
|
81 | BTFSS PORTA,1 ; PRÜFEN OB SW1 GEDRÜCKT; WENN NEIN ÜBERSPRINGE NÄCHSTEN SCHRITT
|
82 | CALL LED
|
83 | GOTO HAUPTSCHLEIFE
|
84 |
|
85 | LED
|
86 | MOVLW B'00000001'
|
87 | MOVWF PORTB ; Bits setzen
|
88 | CALL Pause
|
89 | MOVLW D'5'
|
90 | MOVWF Zaehler3
|
91 | Schleife
|
92 | BTFSC PORTA,1 ; PRÜFEN OB SW1 GEDRÜCKT; WENN NEIN ÜBERSPRINGE NÄCHSTEN SCHRITT
|
93 | GOTO HAUPTSCHLEIFE
|
94 | CALL Pause
|
95 | RLF PORTB ; schiebe Bit in Port B um eins weiter
|
96 | DECFSZ Zaehler3,1
|
97 | GOTO Schleife
|
98 | GOTO LED
|
99 |
|
100 | Pause
|
101 | MOVLW D'250' ; Wert für Zaehler1 ins WReg
|
102 | MOVWF Zaehler1 ; Wert vom WReg in Zeahler1
|
103 | CALL Pause_1
|
104 | DECFSZ Zaehler1,1 ; Dec Zaehler1
|
105 | GOTO $-2 ; wenn Zaehler1 nicht 0 dann springe 2 zurück
|
106 | RETURN
|
107 | Pause_1
|
108 | MOVLW D'250' ; Wert für Zaehler2 ins WReg
|
109 | MOVWF Zaehler2 ; Wert vom WReg in Zeahler2
|
110 | Dek
|
111 | NOP
|
112 | DECFSZ Zaehler2,1 ; Dec Zaehler2
|
113 | GOTO Dek ; gehe zu Pause
|
114 | RETURN ; zurueck zum Ursprung
|
115 |
|
116 | END
|