PDA

View Full Version : fast timer block other interrupts?



flipper_md
- 9th November 2010, 01:05
Hello

I have a pretty fast timer(1) running to draw graphics(POV), interrupt about every 1msec on a 48Mhz PIC (18F2550).
I'd like to be able to change some parameters while this run, but so far I just can't make it respond. Currently testing with DT Instant Int.
I have tried two type of interrupts to stop the Timer1 processing, INT2 and RX_INT, but they get ignored, even if I put a stopper in the Timer routine!?

This is the stopper I have in the Timer1 routine:

if INTb2_RxInc = 1 then ; stop INTERUPTS if incoming Rx
Timr1Start = 0
@ INT_DISABLE INT0_INT
@ INT_DISABLE INT1_INT
@ INT_DISABLE TMR0_INT
@ INT_DISABLE TMR1_INT
ledRFpriority = 1
@ INT_RETURN ; Return to program, (humm that looks clever for instants Ints!!)
; Should add a watch dog for restart
endif

my last resort will be to have a 12F PIC killing the 18F with it's MCLR pin...but that feel weird.

Darrel Taylor
- 9th November 2010, 01:24
A PIC (16F or 18F) can do 1mS interrupts in it's sleep. No pun intended.
Really, that's extremely slow.

Once in the interrupt, another interrupt cannot occur (assumming the first one wasn't Low Priority). So disabling the others doesn't help.

There must be something else going on.
Is there more code available?

flipper_md
- 9th November 2010, 02:06
disabling all other interrupts was done assuming that after exiting the current INT routine, no other interrupt would occur except RX_INT...

the thing that bother me is that once wheel speed is too slow for POV display, I have the same TImer1 interrupt routine to draw less complex graphics,
so it execute a bit faster,
and then It let me update any parameters I want thru RX_INT.

This is as if the PIC won't even read a PIN status when the Timer1 routine is too busy.

I have tried low/high priority INT, but then my timer was behaving poorly


since I have you here Darrel, is it right to put @INT RETURN in a if condition, to exit an interrupt faster than normal?


;--- SIGNAL from Hall Fx sensor B ----------------------------
int1_halfxb:
if INTb2_RxInc = 1 then ; stop INTERUPTS if incoming Rx
Timr1Start = 0
@ INT_DISABLE INT0_INT ; state of interrupts at start
@ INT_DISABLE INT1_INT ; state of interrupts at start
@ INT_DISABLE TMR0_INT ; state of interrupts at start
@ INT_DISABLE TMR1_INT ; state of interrupts at start
ledRFpriority = 1
@ INT_RETURN ; Return to program, (humm that looks clever for instants Ints!!)
; Should add a watch dog for restart
endif
LEDC1 = 1
cled = 0
FinishedPixel = 0
redrawLoop = 0
doDoneTxt = 1 ; this will enter txt display first
ledpattern = 0
pattern_repeat = 3

TMR1H = $00 : TMR1L = $00 ; reload preload max value, we want a little delay

pauseus SensorB_offset ; for fine tuning

if (NoDisplay = 0) and (INTb2_RxInc = 0) then Timr1Start = 1 ; enable pixel timer

@ INT_RETURN ; Return to program





code need a bit of cleanup, I will try to make it more readable soon