Thanks. As I can see, the code is for PIC18xxx family. Will it work on 12xx or 16xx ?
Thanks. As I can see, the code is for PIC18xxx family. Will it work on 12xx or 16xx ?
Not for PIC12's or 16's.
You'll have to download DT's Interrupts for them here and replace entry with:
I was kinda hoping someone would point out my errors in my suggestion, if any, before you went too far into a possible dead end.Code:INCLUDE "DT_INTS-14.bas" ; Base Interrupt System INCLUDE "ReEnterPBP.bas" ; Include if using PBP interrupts
If you haven't tried DT's INTS, you're missing out on some awesome timing control when it comes to sequence of events. It took me a little while to understand but finally got some handle on it when I monitored two interrupts taking turns to run their routines, especially when one occurs while the other ISR is taking care of business.
Louie
Hi,
Ok Louie, I'll take a stab at that if you wish... :-)I was kinda hoping someone would point out my errors in my suggestion, if any, before you went too far into a possible dead end.
If the program is looping around in Loop2 (x=1) when the interrupt occurs the ISR will toggle x to 0 and then GOTO Loop1_Start.
At Loop1_Start there's an @INT_RETURN which will send it back into Loop2 since that's where it was when the interrupt occured.
/Henrik.
Thanks Henrik, I stand corrected.
CuriousOne, I tried to do something like this in the past and thought I came up with a better idea all of a sudden, but to avail.
Louie
I found a sample code here:
http://darreltaylor.com/DT_INTS-14/hello.html
The code is OK for me, since I also need a selected loop indication via led. What if I mod it a like this:
Code:'---[INT - interrupt handler]--------------------------------------------------- ToggleLED1: TOGGLE LED1 IF LED1=1 then goto LOOP1 ELSE GOTO LOOP2 LOOP1: LOOP2: @ INT_RETURN
Sorry for the delay, but I don’t think that would be a good solution since the ISR should only spend enough time in there to update values, take readings, turn things ON/OFF, etc.. Pretty much just get in and get out.
Your example is like the one Henrik suggested but within the ISR.
But got another wild idea if your tight loop can sacrifice just a little time to test the ISR flag bit:
This way, I'm thinking, any one of the loops can complete it's mission before jumping to the other routine should an interrupt happen. Or just continue in it's loop until the button is pushed.Code:INT VAR BIT INT = 0 '------------------------ loop1: code IF INT THEN GOTO loop2 ' Jump to loop2 after loop1 finished if interrupt triggered GOTO loop1 loop2: more code IF !INT THEN GOTO loop1 ' Jump to loop1 after loop2 finished if interrupt triggered GOTO loop2 ; -------------- ISR toggles a flag bit ---------- Button_ISR: INT = !INT @ INT_RETURN
Louie
LOL, I already did in the same way, just it became necessary to rise clock frequency to 32mhz. But I don't use any interrupts, and it works just fine.
Bookmarks