Hallo...
Bin anfänger und möchte gern immer bei Timer0 überlauf eine Led togglen
lassen. Komme aber einfach nicht weiter.
Danke schon mal im voraus
Isr: ;InterruptServiceVector
MOVWF W_TEMP
SWAPF STATUS,W
CLRF STATUS
MOVWF STATUS_TEMP
MOVF PCLATH, W
MOVWF PCLATH_TEMP
CLRF PCLATH
movlw b'00000001'
xorwf PORTB,f ; toggle PORTB
END_ISR ;return to the main program
bcf INTCON, TMR0IF
MOVF PCLATH_TEMP, W
MOVWF PCLATH
SWAPF STATUS_TEMP,W
MOVWF STATUS
SWAPF W_TEMP,F
SWAPF W_TEMP,W
retfie
@Zugvogel: Bevor man losprogrammiert sollte man erstmal wissen was die Aufgabe sein soll. Led toggln lassen ist keine Aufgabe. Auf welchem Mikrocontroller, Taktfrequenz des Mikrocontrollers, Frequenz mit der getoggelt werden soll,an welchem Portpin hängt die Led wären Fragen die man schon beantworten sollte. Auch wenn ich nicht PIC Assembler kann, wenn das da oben dein gesamtes Programm ist, solltest du nochmal ins Datenblatt schauen. z.B. wie geht die Initialisierung des Timers. ISR Routinen...
hallo wolfram ich wollte ja nur mal die abläufe um bei jedem Timer0 überlauf den zustand der led ändert. Als ist bei Timer0 im überlauf die led high dann soll sie beim nächsten überlauf auf low gehen.
Das Toggeln in deiner ISR müsste funktionieren. Ob das Sichern vom W und STATUS hier nötig ist, wage ich zu bezweifeln, schadet aber nichts. Aber: Ich würde sagen, dass das Blinken der LED nicht zu sehen ist. Rechne doch mal die Blinkfrequenz aus.
Du hast leider keine Frage beantwortet Also allgemein Interrupttabelle .. springe zu Timer0_overflowISR .. Timer0_overflowISR: sichere Register die ich in ISR benutze toggle LEDPIN stelle Registerzustand wieder her interruptrücksprung END_TIMER0_overflowISR Hauptprogramm: initialisiere Timer starte Timer endlosschleife End Hauptprogramm
hallo wolfram
das andere ist schon soweit alles eingestellt und das ist auch nicht
meine frage.
ich dachte vieleicht so...
;*********************************
;Interrupt Service Vector Timer0 *
;*********************************
Isr: ;InterruptServiceVector
MOVWF W_TEMP
SWAPF STATUS,W
CLRF STATUS
MOVWF STATUS_TEMP
MOVF PCLATH, W
MOVWF PCLATH_TEMP
CLRF PCLATH
START_ISR
incf count1, f ;count1+1
movlw .100 ;lade 100 im W
subwf count1, w ;subtr w-count1
btfss STATUS, Z
bsf PortB, 1
incf count2, f ;count2+1
movlw .20 ;lade 20 im W
subwf count2, w ;subtr w-count1
btfss STATUS, Z
bcf PortB, 1
END_ISR ;return to the main program
bcf INTCON, TMR0IF
MOVF PCLATH_TEMP, W
MOVWF PCLATH
SWAPF STATUS_TEMP,W
MOVWF STATUS
SWAPF W_TEMP,F
SWAPF W_TEMP,W
retfie
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.