Arduino Mega 2560 - there are differences between the interrupts

Hi all,

I see into the Arduino Mega2560 specification that the Interrupts INT0, INT1, INT2 and INT3 have a line over the name (like a negative sign), the same indication is not present for the INT4 and INT5.

image

The two "groups" have different behaviors in particular coding circumstances?

The INT2 and INT3 are related to the (Serial1 RXD1/TXD1), are affected in case of serial communication for the Serial Monitor? It's true that the Serial Monitor is related to the Serial0 RXD0/TXD0 (pin D0 and D1) ?

thanks,
M.

The processor data sheet is the very best source of information about all aspects of the MCU. If you are interested in using interrupts, you must read the section on the individual interrupt pins very carefully, as they have different capabilities, especially where wake/sleep states are concerned.

Most pins have several mutually exclusive functions, and only one function can be used at any one time.

Yes, Serial0 is connected to the USB interface by a separate MCU (ATmega16U2), so that's what you usually connect the Serial Monitor to.

They have a tilde '~' before the name, the Arduino indicator for PWM capability.

Sorry, I was on the wrong pins :frowning:

Look closer. The OP is talking about a line over the name, not the PWM tilde.

I've spent as much time with the data sheet as I can, and haven't come across what makes those different.

a7

They are very different. ATmega2560 data sheet, page 112:

Note that recognition of falling or rising edge interrupts on INT7:4 requires the presence of an I/O clock, described in “Overview” on page 40. Low level interrupts and the edge interrupt on INT3:0 are detected asynchronously.

1 Like

@jremington THX.

That would appear to answer the OP's question.

a7

I suppose, but it is still a mystery what the artist intended by drawing a line over the interrupt name.

It may signify "static" recognition with no clocking required.

Thanks @jremington for the indications, and also thanks to @alto777 and @DrDiettrich for the contributions.

I ask to all of you to be patient, I'm able to program but my knowledge of the microprocessor is not so good. The "nomenclature" of the datasheet is focused on the micro-controller, and for who like me that are not so familiar with this world, sometimes is difficult to do the correlation with the usage of it into a develop shield. But stop this crying and go work. :slight_smile:

if I have understood there are two different groups of interrupts:

  • group 1 : asynchronous (INT0, INT1, INT2 and INT3)
  • group 2 : requires an I/O clock (INT4 and INT5)

Now new doubts :
first)
For the interrupts that require a clock, How I can give a clock signal, using another pin?
If yes, how define it if the programming references is "attachInterrupt(digitalPinToInterrupt(pin), ISR, mode)"

second)
But, an external clock "in someway" is not like an "external interrupts", I 'm not sure to have transfer what i mean.

third)
The datasheet indicates that the "EICRB" (External Interrupt Control Register B) manage 7 interrupts, but with the Arduino shield we just can use 5, it's correct?

M.

These are not usable in several deep sleep modes.

Sorry, I should have explained the ramifications of the difference in practical terms. I hinted to it in post #2.

External interrupts are often used to wake the processor from deep sleep to process external events, and INT0-INT3 are capable of doing so if a rising or falling edge is detected.

As mentioned above, INT4-7 are not, which makes them less useful.

If you don't study the data sheet and aren't aware of the details, your program will fail in unexpected ways.

Thanks @jremington,
so just to stay practical :

  • if I need to interfaces a Water Flow Sensor like the YF-S401 it's better to connect it to INT0, INT1, INT2 or INT3.
  • if I need to interface a Rotary Encoder I will use INT4 or INT5

right?
M.

If the processor doesn't need to sleep and then be awakened by a rising or falling edge, it probably doesn't matter which external interrupt you choose.

I say "probably" because each new interrupt application requires you to carefully study the data sheet and choose suitable hardware configurations.

Can you do a simple practical example where the processor go in sleep?
Jut to be aligned with my current experiment of reading the water flow, I don't think to have sleep status, or probably not conscious of it.

Aren't the asynchronous interrupts low level sensitive as well as edge triggered? Hence the bar as a reminder.

Battery powered projects do this to greatly extend battery life. The MCU wakes up to process a measurement, store or send the data somewhere, then goes back to sleep. Power savings can be million-fold.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.