Question about DT's Interrupts
I am trying out Darryl Taylors Interrupts but I have a few questions, I am using a 16F628A, and Interrupt on change of Portb pins 7-4.
The first question is do I still need to set up the INTCON=%00001000, or does DT's Interrupt's take care of that.
The second question is in the main program I am trying to get the processor to sleep until there is a change on portb.
@ INT_ENABLE RBC_INT ; enable external (INT) interrupts
siesta:
@ Sleep
@ nop
GoTo siesta
After spending the last week searching the forum for some clarifications, one mentioned that portb needed to be read to see if a change occurred. How do I go about just reading the port to detect a change? What I mean is, yes I can read portb and store it as a variable but if I am constantly comparing then I won't be sleeping right? Or is there another way?
From what I gathered through the PBP manual and the forum, I need to clear the interrupt flag, intcon.1=0 but from what I can tell from DT's Interrupt's it resets the flag. Is this correct?
According to the 16F628A datasheet I only see the use of one NOP so I believe this is correct if not please correct me.
Another question is regarding the enabling the interrupt before the label. This is puzzling to me how when the interrupt is serviced then returning to the main program how would the interrupt be re-enabled. So I was thinking this:
ISR:
'go do something
trisb = $f0
portb = $1
@ INT_ENABLE RBC_INT ; enable external (INT) interrupts
@ INT_RETURN
Is this right?
And my last question is if my program is to start with let say loop: and my main will be the one called Siesta, always keeping it sleeping until a change on portb 7-4, then should I change @ INT_RETURN to @ INT_RETURN siesta?
Thanks for the help
Awaken from sleep when USB connected?
Quote:
Originally Posted by
Bruce
Here's an example of wake up from sleep on change without global interrupts enabled - or an interrupt handler......
And if you do use interrupts, having something similar to CheckState in the beginning of your interrupt handler helps avoid another interrupt when a switch is released.
I still recommend you learn to use DT_INTS though. It's pretty cool stuff...:o
Bruce, an application I am working on needs to awaken from sleep mode when a USB cable is connected. I was using the Darrel's INT_Handler/USB_Handler from his DT_INTS-18 for servicing the USB interrupt to try to do this. However, DT told me in one post that you can't use his USB_Handler to awaken from sleep mode and I should sense the connection of the USB cable with an RB change interrupt and then in the ISR for the RB change do an @RESET to somehow start the USB service. I think I know how to use the RBC_INT from the DT_INS-18 to sense the USB connection but I don't understand how to setup my code to then start the USB service on the sense of the USB connection. If I place the @RESET statement in the RBC_INT handler, what do I have to have in my Main Loop to get the USB service going (application must then dump EEPROM data that has previously been logged over the USB interface to PC which I already have working) and then have it return to sleep mode after the USB is disconnected??