Interrupts on Orangutan X2

I’m a newbie but have managed to get some simple code running on my new Orangutan X2. Everything I’ve done so far is from the AVR Library in C.

Question: If I’m looping a slow operation, is there a way to have a pin-change event immediately kick me out of the loop and return me to the main routine? I know I can check for the event every run through the loop, but if one loop takes (say) one second, then I’m only checking every one second which isn’t responsive enough. I could also check many times within the loop, but that seems inelegant…

Thoughts?

Hello.

Depending on the trigger, an external interrupt might work for your application. What are you trying to trigger off of? Do you have experience using interrupts on AVRs?

- Jeremy

Hi Jeremy, thanks for your reply.

The trigger would be a state change on one of the digital I/O pins. Basically, a 5V pulse would come in, and I’d want to be kicked out of the slow routine I’m in.

I don’t have any experience with AVR interrupts, but then again I’d never written in C before last Wednesday. :slight_smile: Maybe you could point me to the appropriate part of the documentation and I can see if it’s something I’m willing to dive into. :slight_smile:

In the meantime, I’m testing to see whether I can do a new_pulse check every so often during the slow loop operation. When I say I want it to be “responsive”, I’m talking about <250 ms or so – not like 1 ms. So polling might work.

Thanks again,
Mark