Ik krijg helaas een interrupt routine voor de 16F690 niet aan de praat, hoewel vrijwel exact overgenomen uit de PICkit lessons.
Hieronder de assembler source
De bedoeling is voorlopig 4 leds afwisselend aan / uit te zetten (PORTC)
Op dit moment lijkt de interrupt niet plaats te vinden, want PORTC (0-3) LEDs gaan aan en blijven aan (PORTC (4-7) zijn/blijven uit)
het commando comf Display,1 komt dus nooit aan de beurt.
Waar ben ik nu blind?
Dank!
;******************************************************************************
;
; test interrupt routine, try to get it on 1 second, flashing LEDs
; werkt nog niet: interrupt lijkt niet te activeren of gaat maar 1 keer?.
;
; *******************************************************************
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
cblock 0x20
T0Semaphore
Display
endc
; Flag Definitions
cblock 0x70 ; put these up in unbanked RAM
W_Save
STATUS_Save
endc
org 0
goto Start
;***************************** Interrupt service routine *********************************************************
ISR:
movwf W_Save
movf STATUS,w
movwf STATUS_Save
bcf INTCON,T0IF ; clear the interrupt flag. (must be done in software)
; include here ISR counters to reach 1 second (not yet implemented)
; goto ExitISR ; not yet 1 second
ServiceTimer0:
bsf T0Semaphore,0 ; signal the main routine that the Timer has expired
; include alo other actions here that need to be taken when timer is done
comf Display,1 ; invert the LEDs
ExitISR:
movf STATUS_Save,w
movwf STATUS
swapf W_Save,f
swapf W_Save,w
retfie
;****************************************************************************************
Start:
; initialise PORTs
bsf STATUS,RP0 ; select Register Page 1
movlw 0xFF
movwf TRISA ; Make PortA all input
clrf TRISC ; Make PortC all output
; initialise Timer0
movlw B'10000111' ; configure Prescaler on Timer0, max prescale (/256)
movwf OPTION_REG ; configure
bcf STATUS,RP0 ; address Register Page 2
bsf STATUS,RP1 ; address Register Page 2
; initialise PORT A function
movlw 0xF7 ; we want all Port A pins Analog, except RA4
movwf ANSEL
bcf STATUS,RP0 ; address Register Page 0
bcf STATUS,RP1 ; address Register Page 0
; initialise interupt(s)
movlw B'10100000' ; enable Timer 0 and global interrupts:
; bit 7 GIE: Global Interrupt Enable bit
; bit 5 T0IE: Timer0 Overflow Interrupt Enable bit
; bit 2 T0IF: Timer0 Overflow Interrupt Flag bit
movwf INTCON
; initialise Display
movlw 0x0F ; 4 leds on
movwf Display
; MainLoop checks whether interrupt changed variable TOSemaphore, it will then do something
MainLoop:
btfss T0Semaphore,0 ; did the Timer0 overflow?
goto MainLoop ; no - so wait
bcf T0Semaphore,0 ; yes, clear the flag
; and do something
movf Display,0
movwf PORTC ; switch on LEDs
goto MainLoop
end[Bericht gewijzigd door klein is fijn op (0%)]
Je hebt PortC0_AN4, C1_AN5, C2_AN6 op analoog staan.
De interrupt-vector hoort op plaats 0004 in program memory te staan.
I'm with Zonnepaneeltje.
In de trend van:
org 0x0004
;***************************** Interrupt service routine *********************************************************
ISR:
movwf W_Save
movf STATUS,w
movwf STATUS_Save
Ah, bedankt!
Dat was inderdaad het geval.
In de code van de Microchip LPC Demo Board Lessons is dat duidelijk afwezig! bugje.
Dank!