Confused About Interrupts

NoSmoke

Member
The "General Picaxe Manual" states the following about interrupts:

"Does the PICAXE support interrupts?
The PICAXE uses the internal microcontroller interrupts for some of it’s BASIC
commands (e.g. servo). Therefore the internal interrupts are not available for
general use. However the A, M and X parts all support a single ‘polled’ interrupt
on the input port. Use the ‘setint’ BASIC command to setup the desired interrupt
port setting to enable the polled interrupt. The polled interrupt scans the input
port between every BASIC command (and constantly during pause commands),
and so activates very quickly."

It also states in a tutorial section "Using Interrupts":

"A polled interrupt is a quicker way of reacting to a particular input combination.
It is the only type of interrupt available in the PICAXE system."

However the hintsetup command apparently sets up hardware interrupts on the X2 chips which I would gather interrupt after execution of a hardware level rather than a Picaxe instruction (this being much faster esp on Picaxe blocking instructions(?)).

Is the documentation out of date or is my understanding of it incorrect?
 

Buzby

Senior Member
Hi NoSmoke,

Polled ot not ?

Well, it's a bit of both !.

Normal PICAXE interrupts are just a piece of code that is run 'between' normal PICAXE instructions.
This code looks to see if any of the current interrupt requirements are set, and if so go an execute the interrupt subroutine.
This test is only done between PICAXE instructions, so if a condition came and went before it got tested there would be no interrupt.

When hintsetup is used, the hardware interrupts are enabled. A hardware interrupt will then, at any time, set a hint flag.
When the PICAXE firmware is next 'between' instructions, this time it checks to see if any hint flags are set, and executes the subroutine if needed. .

The benefit is that the hint flag will stay set, even if the cause of the interrupt has gone before the firmware gets round to checking, so there is far less chance of missing a transient interrupt event.

The response times are still the same, because it's still polling, but there is far less chance of 'missing' an interrupt.

Cheers,

Buzby.
 

NoSmoke

Member
Thanks for the explanation Buzby. So then, even a hardware interrupt will not interrupt a count instruction for example?

What about settimer though? The docs state the timer cannot be used along side a servo comand but does it keep acurate time count with other instructions such as count, pause, serial i/o or debug?
 

hippy

Ex-Staff (retired)
So then, even a hardware interrupt will not interrupt a count instruction for example?
No. HINTESETUP just allows signal changes or events to be flagged to cause an interrupt when the COUNT ( or any other command ) completes.
 
Top