Ist die falsche Version, krieg ich irgendwie nicht editiert.
Also nochmal
Code:
;*************************************
;
; Includedatei für den PIC16F628A
list p=16f628a
include "p16f628a.inc"
;*************************************
; Configuration festlegen
; 8Mhz Resonator: Brown out Reset on, Data Protection off, Power up Timer on, Watchdog off, LV-Programmierung off
__CONFIG _BODEN_ON & _CP_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_OFF & _HS_OSC & _LVP_OFF
;***** VARIABLEN******************
w_temp EQU 0x70 ; context saving
status_temp EQU 0x71 ; context saving
Flags equ H'0072' ;
count equ H'0020'
tempa equ H'0021'
tweek equ H'0022'
Blk equ H'0023'
;*********************************
; Pinfunktion festlegen
org 0x0000 ;Programmstart
goto INIT
org 0x004 ; Interruptbehandlung
INTSERV movwf w_temp ; W register retten
movf STATUS,w ; status register nach W register
movwf status_temp ; STATUS register retten
bcf STATUS,RP0 ; Bank0
bcf STATUS,RP1
; hier kommt später Code hin
; für eventuelle Interrupts
IntEnd movf status_temp,w ; STATUS register
movwf STATUS ; wieder herstellen
swapf w_temp,f
swapf w_temp,w ; W register wieder herstellen
; ( Inhalt wie vor Interrupt)
retfie ; Rücksprung aus Interruptbehandlung
;****************************************************************
INIT clrf INTCON ; keine Interrupts zulassen
bcf STATUS,IRP
bcf STATUS,RP0
bcf STATUS,RP1 ; Bank0
movlw 0x07 ;Comperators off
movwf CMCON ;I/O Funktion ermöglichen
clrf PORTA
clrf PORTB ; alle Ausgänge Low
BCF STATUS, RP1 ;Bank 1 auswählen
BSF STATUS, RP0
movlw 0x3F ;Pins config
movwf TRISA ;PORTA 0-5 Input
movlw 0x00 ;PortB Output
movwf TRISB
bcf STATUS, RP0 ;Bank 0 auswählen
; hier bei Bedarf andere Register
; für Timer,CCP,EEprom,Usart,Vref
; initialisieren
;***********************************************
;Taster abfragen , Led ausgeben
;Hier steht das eigentliche Programm
;
Start movlw 0xff
movwf PORTB ; alle Led an
movlw 0x05
movwf Blk ; Schleifenzähler Blinken
Blink call DELAY250 ; 0,25 sec warten
movlw 0xff
xorwf PORTB,f ;
decfsz Blk,f ; Schleife Blink 5 mal durchlaufen
goto Blink
Loop btfss PORTA,0 ; überspringe nächsten Befehl,wenn Taster nicht gedrückt
goto LedAn
bcf PORTB,0 ; Led aus
;andere Aufgaben hier
goto Loop
LedAn bsf PORTB,0 ; Led an
goto Loop
;**********SUB _Routinen für Warten*************************
DEL1MS movlw D'198' ;t=(n-1)*5+2(call)+6(ret)+7(Kopf)
movwf count
nop
goto $+1
goto $+1
DLY1MS goto $+1
decfsz count,f
goto DLY1MS
return
DELAY250 movlw D'248'
movwf tempa
DLY250 call DEL1MS
decfsz tempa,f
goto DLY250
movlw D'83'
movwf tempa
TWEEK250 decfsz tempa,f
goto TWEEK250
movlw D'250'
movwf tempa
DLY251 call DEL1MS
decfsz tempa,f
goto DLY251
movlw D'83'
movwf tempa
TWEEK251 decfsz tempa,f
goto TWEEK251
return
end
Lesezeichen