Well, that PAUSE 100 was provided just as filler - at such rate, leds going to blink rapidly. I believe, PAUSEUS 100 would be much better, but PBP PAUSEUS accuracy is far from desired.
Well, that PAUSE 100 was provided just as filler - at such rate, leds going to blink rapidly. I believe, PAUSEUS 100 would be much better, but PBP PAUSEUS accuracy is far from desired.
If that code is in your interrupt, the interrupt can never exit and you might as well have put this in your main program.
You can’t run a continuous loop. The ISR is always a call i.e.. GOSUB, and you always have to return from interrupt or your main code will never run.
What is currently triggering the interrupt?
Also, it looks like you want PWM at 50% duty cycle, but if more than one condition is true, it will break all of them.
There is a thread a little below about frequency counters. Darrel didn’t want to shove his own timer code down someone’s throat,
but it was really the answer to the problem. To his merit, he gave advice about a less efficient manner the OP was already working on.
Similarly DT’s code is the answer to your problem.
Last edited by Art; - 7th April 2015 at 10:30.
It looks to me you want three software PWM channels, all 50% duty cycle 100ms ON/100ms OFF,
that you switch on & off based on the values in variables A,B & C.
Even though this code won’t do that, I don’t understand why you check X=1, X>1, X>2, all for the same result.
Could you have just:
and then the same for B & C?Code:IF A != 0 THEN HIGH LED1 PAUSE 100 LOW LED1 PAUSE 100 ENDIF
Just want to be sure of what you want to do.
Just checked, sorry, I've pasted ENDIF at wrong place. It should look like this
and so on, for all LEDS and cases.Code:SOFTPWM: IF A=1 THEN HIGH LED1 ENDIF PAUSE 100 LOW LED1 PAUSE 100 GOTO SOFTPWM
I want to run this code in background of main task, so this is why I wanted to use interrupt. Seems like it is impossible?
You mean you want to run the above lines of code as an interrupt? I don't think so.... The pauses will kill you.... What is your anticipated interrupt period?
By the way, What processor are you using and at what frequency?
Last edited by Dave; - 7th April 2015 at 11:53.
Dave Purola,
N8NTA
EN82fn
I want to run this task in a way, that main task won't interfere with it, nor it execution will affect main task.
Processor can be any of 16F family at any possible frequency.
It’s not the pauses, the loop never ends:
Only your main program can do that.Code:SOFTPWM: code GOTO SOFTPWM
This ISR doesn’t allow your main program to ever run once it’s called.
Bookmarks