Skip to content

How to enable interrupts on Arduinio Uno's INT0/D2 #326

Answered by Rahix
jeroenvlek asked this question in Q&A
Discussion options

You must be logged in to vote

You have to actually enable the external interrupt/pin change interrupt machinery. Pin PD2 can be either INT0 as an "external interrupt" or PCINT18 as a "pin change interrupt". For "external interrupts" you can control on what edge the interrupt should trigger while for "pin change interrupts", any edge will trigger it.

The example @tsemczyszyn linked shows how to set up the PCINT18 "pin change interrupt".

The INT0 ISR in your code would be for the "external interrupt". To enable it, for example on a falling edge, this piece of setup code would be needed (untested):

// Configure INT0 for falling edge. 0x03 would be rising edge.
dp.EXINT.eicra.modify(|_, w| w.isc0().bits(0x02));
// Enable …

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Rahix
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #240 on September 02, 2022 10:52.