Go Down

Topic: interrupt priority Arduino DUE (Read 429 times) previous topic - next topic

DUEDUE

Hi there Im using 4 software interrupts I would like now to use an extenal hardware interupt as an emenrgency  button.


Can I change or set the proprity of the interrupts ??


PaulS

Quote
Can I change or set the proprity of the interrupts ??
No. The priority is defined in the hardware.

Since an interrupt is supposed to be handled quickly, you should not need to mess with the priority. That you think you need to suggests that your interrupt handlers are not quick. It is far more important that you fix that, or quit misusing interrupts, than it is to diddle with the priority.

DUEDUE

Hi thanks for your reply

the ASF Atmel Software Framework offers


NVIC_SetPriority(TWI1_IRQn, 0)

I just want to use the same at my arduino due borad to set the highest priority for my hardware emegergency botton interrupt


I hope that you got what I mean

wildbill

Why bother? It sounds like the vast majority of time taken will be that expended by the operator deciding to push the emergency stop. You could be polling the button, and provided you haven't used delay in your code, it'll be blazingly fast.

Or is the emergency stop being triggered by the arduino too?

DUEDUE

My Emergency Stop is a soft stop.. so it just will deactivate all the interupts when the user push a button ( Hardware Interrupt)

and I saw that ASF provides in the NVIC header (Nested Vektor Interupt Control)

a priority choice for the interupts handler so I can decide which interuptshandler shall have a high piority through

  NVIC_SetPriority(firstHandler, 0);
Im just wondering if can  apply the same under Arduino DUE

PaulS

Code: [Select]
Im just wondering if can  apply the same under Arduino DUE
I'm just wondering when you are going to take the hint and POST YOUR CODE!

Well, enough hinting. POST YOUR CODE.

You are almost certainly using interrupts incorrectly. Processing the "emergency stop button" (a switch seems far more useful than a button) after the current serial byte has been received or after the current clock tick has happened doesn't REALLY seem like it is going to cause that much difficulty.

After all, some human has seen a problem, decided that something needs to happen, and slapped the switch. Reacting to that within nanoseconds then seems silly.

MarkT

A good reason to use an interrupt for an emergency stop switch is to guarantee that it
will be noticed, not to notice it with microsecond accuracy (which isn't a good reason).

This means that only the interrupt handler has to be correct for the emergency stop actions
to work as expected - if you poll the entire code of the sketch has to be correct and real-time
which isn't as plausible.
[ I won't respond to messages, use the forum please ]

Collin80

and I saw that ASF provides in the NVIC header (Nested Vektor Interupt Control)

a priority choice for the interupts handler so I can decide which interuptshandler shall have a high piority through

  NVIC_SetPriority(firstHandler, 0);
Im just wondering if can  apply the same under Arduino DUE
Sure. Use that exact same function even. Just call NVIC_SetPriority with the proper interrupt and priority and it'll work. The only catch is that you need to figure out the proper value for the interrupt you're interested in. This can be found within the Arduino core source code or you can look it up in the ASF documentation.

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