difference in interrupt speed

oracacle

Senior Member
Before I start trying to measure interrupt response times I am hoping that there is someone here who may have done the work already.
My current project make use of setintflags and the comparator as the sensors are mostly analogue, how ever with some sensor can be used in a digital capacity which got me to thinking:- Is the hardware interrupt faster than the setintflags which a presume is a software interrupt?

I did a quick measure ages ago and from memory the comparator interrupt is about 200us @64mhz using a 28x2. I am thinking about moving the project over to 20x2 and it looks as though there maybe a few of pins left over, that combined with some sort of picaxe controlled switch setup (maybe a solid state relay) to switch the input from the ADC pin to a hardware interrupt maybe possible if its worth while.
 

Buzby

Senior Member
setintflags just tells the PICAXE what interrupt to use, it does not affect the response times.

The big difference with the hardware interrupt is that it can detect a change on a pin during the execution time of a PICAXE instruction, whereas the normal interrupt only checks for changes between PICAXE instructions.

However, even with hardware interrupts, the PICAXE can't process the interrupt until the current instruction has finished, so the response times are much the same.

The advantage of HW interrupts is that if a *very* short pulse occurs it can be detected, even if it is over before the PICAXE firmware sees it.

I think your first task is to determine how fast you need the response to be, then see if a PICAXE can do it.

Cheers,
Buzby
 

hippy

Technical Support
Staff member
Is the hardware interrupt faster than the setintflags which a presume is a software interrupt?
What "hardware interrupt" ?

There are two interrupts the user has access to on a PICAXE; SETINT which polls the inputs between commands and triggers when the selected input pins match a particular mask, and SETINTFLAGS which latches hardware events, then polls those latched events between commands and triggers an interrupt when required.

HINTSETUP is used to specify the hardware events to detect and latch, doesn't actually trigger an interrupt itself.
 

oracacle

Senior Member
Ok you both answered the that. Didn't realise that HINTSETUP was basically the same as SETINT and SETINT FLAGS.
The system will be in fast loop to check a single the HSERPTR (old system check for a pin going high) to exit the loop and disable the interrupt.
I was just thinking about trying to squeeze a little more speed out - not that it particularly slow as it stands
 

hippy

Technical Support
Staff member
It can often be best to describe what one wants to achieve as that may elicit the most appropriate answer.

The fastest response to a serial byte received will probably be to poll the 'hserflag' and not actually use interrupts -

Code:
ReadSerialByte:
  hSerFlag = 0
  Gosub InitiateReceive
  Do : Loop Until hSerFlag = 1
  Gosub ByteReceived
  Return
 

oracacle

Senior Member
the interrupt doesn't relate to the hserin. The system will receive either high or low going pulse from an external sensor. this pulse can (in theory at least) be analogue in nature. The original used the ADC comparator and SETINT FLAGS set for that. The hserin is to look for input from a nextion display. I am essentially building a new version of my high speed photography unit. The new version only exists as software so far

so at the moment:
Code:
setintflags for comparator
do
  if hserptr >0 then exit
loop
'continue code

interrupt:
  'do stuff
  return
The old system did essentially the same but looked for a switch press instead. I thought that if I'm going to be making changes I just as well do it as I am assembling the new code and design the new hardware around that. But seeing as its not really going to make much difference I will keep the current design for the time being
 
Top