PDA

View Full Version : DT interrupt problem



eggman
- 14th June 2012, 12:29
Hello everyone, I'm having trouble making my program work. I'm using DT interrupts to measure the duration of a servo pulse using CCP interrupts.
The interrupt routine works as expected but it doesn't return to the Main program, I'm missing something. Any input is appreciated.
Code:




#config
__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
#endconfig
define OSC 8
Include "modedefs.bas"
INCLUDE "DT_INTS-14.bas" ; Base Interrupt System
INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts

ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler CCP1_INT, _pulsedata, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM

@ INT_ENABLE INT_INT ; enable external (INT) interrupts

GPIO = 000000
TRISIO = 000101
ANSEL = 000000
CMCON0 = 000111
OSCCON = 110000 '8MHZ
PIE1 = 100000
INTCON = 010000
T1CON = 000001 'no prescaler
CCP1CON = 000101 'rising edge CCP
led var GPIO.5
wsave VAR BYTE $20 SYSTEM ' location for W if in bank0
pulse var word 'received pulse width

clear

Main:
pause 100
toggle led
GOTO Main

'---[INT - interrupt handler]---------------------------------------------------
pulsedata:
if CCP1CON.0 = 0 then
pulse.lowbyte = TMR1L
pulse.highbyte = TMR1H
' serout 4,N9600,[#pulse,13] 'for testing
CCP1CON.0 = 1 'rising edge CCP
else
TMR1L = 0
TMR1H = 0
CCP1CON.0 = 0 'falling edge
endif
@ INT_RETURN


end

HankMcSpank
- 14th June 2012, 15:28
I'm no expert, but you've created a
CCP1_INT interrupt, then done this...






@ INT_ENABLE INT_INT ; enable external (INT) interrupts


to my way of thinking (possibly wrong!) it should be this...






@ INT_ENABLE CCP1_INT ; enable CCP1 interrupt


(that's assuming you want to interrupt on CCP1 & not the INT pin?)

eggman
- 14th June 2012, 16:11
Thanks for the suggestion, but my interrupt routine works okay. I tried it but it makes no difference. Somehow it will not run the main program, it will handle all the interrupts though.

ScaleRobotics
- 14th June 2012, 17:07
What if you change the pause from 100 to 15?

Darrel Taylor
- 14th June 2012, 20:38
Although the forum has messed up your binary numbers (as usual), you can still see problems.

You have enabled INTE in the INTCON register, but there is no handler for INT_INT.

You have enabled RCIE in the PIE1 register, but there is no handler for RX_INT.

It never returns to you program, because the interrupts are never handled.

eggman
- 15th June 2012, 09:08
Thank you Darrel for pointing me in the right direction, it works fine now!