Interupt

Jaguarjoe

Senior Member
The book says that only an input can trigger an interrupt. Is there a way to get a variable to tigger an interrupt?
 

Dippy

Moderator
Do you mean like setting the code so that, for example, if b0=17 then interrupt?

If so, I don't reckon so, interupts are related to hardware events (e.g. port.pin changes), WDT timeouts, and other thing I can't remember.
Have a look at PIC Data Sheets to see what peripherals can generate an interrupt. PICAXE allows only hardware port changes I believe.
 
Last edited:

Jaguarjoe

Senior Member
Maybe there's another way to do what I want.

I would like to reset a pause time period and give it a new value while the pause is active. Issuing a reset command during the pause would be OK.
 

BeanieBots

Moderator
The 28X1 can have a timer interrupt. Maybe there is some scope there for what you want.
Another way might be to break down the "pause" into small segments in say a for/next loop with a test at each step.
Not EXACTLY what you want to do.
 

Dippy

Moderator
So, you want to interrupt a pause while the command is executing.
Nope.

(If I have understood): How about little pauses in a loop with an IF test to pop out and modify? I don't know how fast you want to do all this, you haven't indicated.

Only alternative is to part with a couple of hundred quid and try PIC programming. Same when wanting to interrupt a Sleep.

Or use BB's suggestion....
 

RobertN

Member
Hardware loop for interupt

Couldn't you have an interupt on b0=17 then output x high, with output x wired to input y, and read the interupt on input y?
 

Dippy

Moderator
How does b0=17 make an output high?

I don't know if you could maybe make a port=value and use interrupt on change??? Or use your wire idea.

But that's to do with the first query, not the second isn't it.
 

Jeremy Leach

Senior Member
Jaguarjoe said:
I would like to reset a pause time period and give it a new value while the pause is active.
Still not sure what you are trying to do JJ. Sounds like the code starts to pause then changes it's mind on how long to pause for. That's quite an unusual situation.
 

Dippy

Moderator
There seemed to be 2 questions Jezzer.
Dunno whether they were related.
1) Can a change in a variable value be used to trigger an interrupt.
2) Can a 'pause' statement be interrupted during execution.
Straight answer to both = No.
 

hippy

Ex-Staff (retired)
Actually ...

1) No, variable values cannot cause an interrupt
2) Yes, PAUSE statements can be interrupted during execution.
 

Jaguarjoe

Senior Member
Still not sure what you are trying to do JJ. Sounds like the code starts to pause then changes it's mind on how long to pause for. That's quite an unusual situation.
I have an ADC channel output variable which is used as the pause value in a ring counter. The higher the ADC output, the faster it cycles. At high pause values ( many seconds) I have to wait for the pause to time out before I can fetch a new ADC value and pause at that corresponding value which gives me a different cycle time. In a nutshell, the program stops while executing the pause and won't update the ADC while it is stopped there timing out. As previously mentioned, 3 or 4 mini pauses instead of one long pause will lessen the effect by a factor of 3 or 4 and would be OK even though its not the ideal way of doing this.
 

Jeremy Leach

Senior Member
Ah, thanks for explaining - yep makes sense. I can't think of a better solution than breaking the pause up. Should be effective. Perhaps something like:
Code:
'Init
PauseCounter = 0
OldADCValue = 0

'Main
DO
    Pause for a fixed short time

    Read ADCValue
    If ADCValue <> OldADCValue Then
        Threshold = ADCValue * 10 (or whatever calculation you like)
    EndIf
    OldADCValue = ADCValue
    
    Inc PauseCounter
    If PauseCounter >= Threshold Then
        PauseCounter = 0
        Do something to do with your ring counter
    EndIf

LOOP
 
Top