Hello All,
Darrel,
I love the Instant Interrupts. Is it possible to use it with multi SPWM? I need a system LED that just blinks at a constant speed like 4 times a second. to show that the pic is working.
Hello All,
Darrel,
I love the Instant Interrupts. Is it possible to use it with multi SPWM? I need a system LED that just blinks at a constant speed like 4 times a second. to show that the pic is working.
Best Regards,
Kurt A. Kroh
KrohTech
“Goodbye and thanks for all the fish”
I rewrote the old SPWM module to work with DT_INTS some time ago.Is it possible to use it with multi SPWM?
DT_INTS-14 (SPWM_INT - Multiple Software PWM)
http://darreltaylor.com/DT_INTS-14/SPWM.html
But if you just want to blink an LED at a certain rate, the Timer Template might be more appropriate.
DT_INTS-14 (Timer Template)
http://darreltaylor.com/DT_INTS-14/TimerTemplate.html
<br>
DT
Oh, sorry I forgou to mention I am using an 18F PIC. Can I use the timer template -14?
Best Regards,
Kurt A. Kroh
KrohTech
“Goodbye and thanks for all the fish”
You're talking about one of my favorite 'staples' whenever I build something...I call it a 'heartbeat'...
I have an LED connected to a specific pin...
I set up Timer 0 to run at a decent rate according to my main clock speed...i.e. once per second-ish, 4 times per second-ish, doesn't really matter, as long as I can see it blink.
Then every Timer 0 overflow, I increment a byte variable, last I set the LED to follow a certain bit of that variable.
So, say I use 'temp' as my variable.
myint:
temp = temp + 1
led = temp.0 'led will flash on/off every other time thru loop
resume
If the LED flashes too fast, I use temp.1, still too fast, maybe temp.2.
Or, conversely, if I use temp.4, and that flash is too slow, I'll use temp.3, or temp.2, whatever...until I find a flash rate that works for me.
DT's Fast interrupts and SSPWM code are great pieces of code...but I think they're big time overkill for what you want...
An example cut from one of my last programs:
IF you're not using a '4620, then you'll have to figure out which registers need which values as far as interrupt and timer registers go.Code:'CONFIG statements semi-permanently set in PBP 18F4620 .INC file resetplaceholder: '18f4620 code DEFINE OSC 10 DEFINE NO_CLRWDT 1 'no extra clear watchdog timer instructions DISABLE CLEAR led1 var porta.5 heartbeat var byte startupholder: goto skipsubs 'skip over all the commonly used subroutines ON INTERRUPT GOTO INTHANDLER DISABLE INTHANDLER: if intcon.2 = 1 then 'timer 0 overflow interrupt handler intcon.2 = 0 heartbeat = heartbeat + 1 led1 = heartbeat.0 'led flash about every ~1.6 seconds ' change heartbeat.0 to heartbeat.X where x = 0 - 7 to change heart beat flash rate INTFINISH: RESUME DISABLE 'end of commonly used subroutines, skipsubs block for setting up registers, lcd, whatever else... skipsubs: t0con = $84 intcon = $e0 cmcon = 7 pie2 = $80 trisa = 0 porta = 0 led1 = 0 output led1 ' change prescale value in $84 to change flash rate ENABLE mainloop: ' do something useless or useful here goto mainloop END
I chose porta.5 because it was available. Change that to what you need also.
Last edited by skimask; - 9th February 2008 at 06:53. Reason: Removed runny colons....nya nya... :D
I'm thinking just the Blinky example is all you need.
DT_INTS-18 (Blinky Light)
http://darreltaylor.com/DT_INTS-18/blinky.html
Or, even better ...
DT_INTS-18 (Assembly Language Interrupts)
http://darreltaylor.com/DT_INTS-18/asm_ints.html
Same Blinky LED, without the Basic Language Interrupt overhead.
And no running Colon's
<br>
DT
Yes, this is the code I am using but I can't get it working in the same program as the multi SPWM. I am useing multi SPWM for my 8 pwm dimmers.
Also I have played with the prescaler to slow down the blink rate but have had no sucess. is there a formula for this like in the -14 version?
I will also make an attempt to digest Skymask's timer 0 overflow interrupt handler in the morning.
Thanks Darrel and Skymask. You are both very helpful.
Best Regards,
Kurt A. Kroh
KrohTech
“Goodbye and thanks for all the fish”
The original SPWM will not work with Instant Interrupts.
They both want complete control of the interrupts. (can't happen)
However, SPWM_INT will work with Instant Interrupts.
And yes, the version shown in the -14 section will work on the 18F's too.
DT_INTS-14 (SPWM_INT - Multiple Software PWM)
http://darreltaylor.com/DT_INTS-14/SPWM.html
SPWM_INT uses Timer1, so if you also want a Blinky light, you'll need to use a different Timer. (0, 2 or 3)
And if you want to use either of the SPWM versions, then you can't use skimask's code.
They are not compatible with ON INTERRUPT.
<br>
DT
Bookmarks