Go Down

Topic: Attach multiple interrupts on the due? (Read 309 times) previous topic - next topic

mistergreen

Mar 17, 2015, 04:54 am Last Edit: Mar 17, 2015, 05:03 am by mistergreen
i read only one interrupt can run at a time for the uno, mega; same for due?

MarkT

The ARM has a priority interrupt system I recall, so I believe many interrupts can be
active at once, but the datasheet will need to be consulted to confirm this for the SAM3X
(unless someone else here knows already)
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

mistergreen

#2
Mar 17, 2015, 04:48 pm Last Edit: Mar 17, 2015, 04:49 pm by mistergreen
Yeah, the Due can set an interrupt on any pin, not sure if it can do multiples at the same time. Any quick way to test that?

LMI

Is it really necessary to run more than one of them at same time. Often it is enough to have many interrupts but only one runs at a time. Interrupts routines should be short and quick so it does not matter usually.

It is probably possible to enable interrupts within interrupt procedure but I don't know/remember how. Running many interrupts at a time just create problems like endless interrupts and stuck Arduino.

mistergreen

Is it really necessary to run more than one of them at same time. Often it is enough to have many interrupts but only one runs at a time. Interrupts routines should be short and quick so it does not matter usually.

It is probably possible to enable interrupts within interrupt procedure but I don't know/remember how. Running many interrupts at a time just create problems like endless interrupts and stuck Arduino.
Yeah, that's the problem. I have a water flow sensor that sends pulses 24/7. Interrupt gives the most accurate frequency. But it's running all the time. Should I use pulseIn?


LMI

I don't think you need an interrupt for that and surely not many interupts. When you get a pulse the interrupt routine starts, does it's work and stops. Then it is ready for an other interrupt. The interrupt part should be quick, that is short. Then main program does the rest. Or have I misunderstood what you need?


There is info about interrupts in "attachInterrupt()" http://arduino.cc/en/Reference/AttachInterrupt in Learning section.

MarkT

Is it really necessary to run more than one of them at same time. Often it is enough to have many interrupts but only one runs at a time. Interrupts routines should be short and quick so it does not matter usually.

It is probably possible to enable interrupts within interrupt procedure but I don't know/remember how. Running many interrupts at a time just create problems like endless interrupts and stuck Arduino.
With priority interrupt systems only ISRs of a higher priority than the currently running
code can interrupt (rather than be queued).  This means that high priority ISRs can
interrupt lower priority ISRs and you can thus allow more things to be driven with
interrupts, some can be quite time consuming so long as the higher priority things
are mapped to high priority interrupts.  There's a lot of benefit from this in large systems.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

RayLivingston

You absolutely do not need nested interrupts just to monitor a flow sensor.  The pulses will be coming years apart in CPU time.  All the ISR needs to do is increment a counter, maybe set a flag, then return.  Whatever else needs to be done can be done in the foreground task.

Regards,
Ray L.

MarkT

You might want them if you have another higher-speed device - then its ISR can
interrupt the flow-sensor's ISR.

But you wouldn't go out of your way unless there was a need.  If they are already
prioritized its wise to choose a sensible priority level from the get-go.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

mistergreen

Thanks for the advice.

I just read that more advance ARM chips like in the mobile phones are capable of threading or multiple processing but not the small Due ARM. One day maybe :)

RayLivingston

You might want them if you have another higher-speed device - then its ISR can
interrupt the flow-sensor's ISR.

But you wouldn't go out of your way unless there was a need.  If they are already
prioritized its wise to choose a sensible priority level from the get-go.
For that to be an issue, you'd either be spending WAY too much time in an interrupt handler, or the flow sensor pulses would have to be come REALLY fast.  The first is fixable by writing the code better and the second seems to me highly unlikely.

Regards,
Ray L.

RayLivingston

And, BTW, for a simple flow sensor, that only needs to count pulses, you can use a hardware timer as a counter, and not need the interrupt at all!

Regards,
Ray L.

MarkT

#12
Mar 19, 2015, 01:00 am Last Edit: Mar 19, 2015, 01:00 am by MarkT
For that to be an issue, you'd either be spending WAY too much time in an interrupt handler, or the flow sensor pulses would have to be come REALLY fast.  The first is fixable by writing the code better and the second seems to me highly unlikely.

Regards,
Ray L.
Only the high priority things have to be superfast, the lower the priority the less it matters,
since they are less urgent and do not hold up anything of a higher priority.  You
shouldn't be making an urgent event a low priority interrupt of course.  Think of a virtual
memory system where any instruction or data access could trigger a page fetch and
block the process for many ms - that's exactly analogous to an interrupt that lasts several
ms to the program, but all the urgent stuff still gets handled during that time.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy