hallo beste mensen,
ik ben bezig om een interrupt te maken, tot zover is dit gelukt met behulp van deze site.
maar ik loop op 1 ding vast.
wanneer ik dit stuk programma uitvoer, dan kan ik de interrupt activeren maar wanneer de pic dit stukje code heeft afgehandeld, dan vervolgd hij niet meer waar deze gebleven is.
wie kan mij helpen?
---------------------------------------------
;Interrupt RB0
DEVICE = 16F628A
CONFIG HS_OSC, CP_OFF, WDT_OFF, PWRTE_ON, LVP_OFF, MCLRE_ON, BODEN_off
XTAL 20
DELAYMS 200
ALL_DIGITAL=true
PORTB_PULLUPS=true
DELAYMS 200 ' allow pic to Stabilize
PORTA=0
TRISA =%00000000
TRISB =%00000001
' Interrrupt symbols
SYMBOL GIE = INTCON.7 ' Global Interrupt Enable
SYMBOL INTEDG = INTCON.6 ' External Interrupt Edge selection
SYMBOL INTE = INTCON.4 ' External RB0 Interrupt Enable
SYMBOL INTF = INTCON.1 ' External Interrupt Flage
' interrupt initialiazation
OPTION_REG.6=1 'Set External Interrupt Edge to falling edge
WHILE GIE=1 ' make sure to disable the Global interrupt
GIE=0 ' Disable Global interrupt
WEND
' Clear interrupt sources flages and enable them
CLEAR INTF ' Clear INT Flag
SET INTE ' Enable External RB0 Interrupt
SET GIE ' Enable Global interrupt ( 0 disable)
ON_Interrupt GOTO ISR
GOTO Main ' Jump over ISR
'************************************************* ******
ISR: 'Interrupt Service Routine
' The GIE is disabled automaticly by hardware to
' prevent Interrupt while excuting the ISR
IF INTF = 1 THEN ' Check if external interrupt
PORTA.2=1
DELAYMS 500
INTF = 0 ' Clear INT Flag (be ready for the next
PORTA.2=0
DELAYMS 500
ENDIF
PORTA.2=1
DELAYMS 500
CONTEXT RESTORE
' The GIE is enabled automaticly by hardware
' to make it ready for new interrupt
'*******************************************
Main:
PORTA.1=1
DELAYMS 500
PORTA.1=0
DELAYMS 500
GOTO Main
END
---------------------------------------------
mvgr. Ruud
marcob
Honourable Member
People tend to overestimate what can be done in one year and to underestimate what can be done in five or ten years
In het voorbeeld doen zet het zo, probeer dit eens:
DISABLE ' Disable interrupts in the handler
My_Int:
TOGGLE LED ' Toggle an LED when interrupted
RESUME ' Return to main program
ENABLE ' Enable interrupts after the handlerFrits Kieftenbelt
Ohm sweet Ohm | www.picbasic.nl
Download en bekijk ook eens het programma van de automatische theezetter, die maakt gebruik van de PORTB.0 interrupt.
Download link onderaan pagina: www.picbasic.nl/theezetter.htm