Interruption pins

Hi,

I am using Arduino ATMega (1280) and I would like to confirm if I am really in trouble… Or there is no way to solve this issue?

  • I need an interruption pin to wake-up the processor.

  • I am already using INT0 and INT1 (pins Digital 2 and 3) as interruption pins to wake-up the MCU(working fine).

  • I am using the I2C bus, so INT3 and INT4 (pins Digital 21-SCL and 20-SDA) cannot be used. There are more than one device on this bus and I do not want (I am afraid of…) to include a hardware line on it to serve as an interruption pin…

  • Serial1 interface is being used (actually, I am using all 4 serial interfaces). therefore, INT4 (RX1) and INT5 (TX1) cannot be used.

thanks

Search for "pin change interrupt".

Or use diodes, like here: Any of cathodes going low causes a low interrupt on the common anode, which is an input with internal pullup resister enabled.

Thanks for the replies!

The diode idea is very good and it is definitely an option for me. While waiting for the replies, I had an idea. I am using one of the serial ports (Serial3) for a serial LCD. Therefore, I can swap Serial1 with Serial3. In this way, the RX1 pin will be available (LCD only receives data) and I can use this pin for this purpose.

Question: If I am using Serial1 (say, Serial1.begin(9600), etc...) for a serial LCD, can I still use the RX1 pin for interruption purposes or it compromised in someway with the serial library?

Thanks.

Re: Serial1 - I don't think so, unless you use Serial1.end, and then pinMode to set the pin to an input, and then Serial1.begin again later to turn it back on. Otherwise I would expect your signal will likely just be seen as a start bit and fill the hardware buffer byte with 0s or 1s.

If you want to get an interrupt when you get serial data you can run a wire from the Rx pin to another interrupt pin. But you can’t use Rx to handle a separate interrupting input. As CR says, the UART will have a hernia.

What is this other interrupt source, and why would it need to share the Rx pin?


Rob

Let me explain better the idea of using Serial1 and let me know if it will work...

  • The external interrupt pin INT4 shares the same pin as RX1 (the receive line of Serial1)

  • Serial1 is being used for LCD only; therefore, TX1 pin is being used but RX1 is not used at all; in other words, in the code I never read from Serial1

  • When sleeping, the Serial1 is not being used; in fact, before going to sleep, I shutdown many hardware pins and I also use Serialx.end()

  • Therefore, I believe that I can use INT4 (same pin as RX1) to wake-up the MCU

Comments?

I think that would work, won't know for sure until you try. Do the serial1.end, pinmode(RXpin, INPUT) digitalWrite(RXpin, HIGH) attachInterrupt(whatever it is, LOW), etc.

Another thought:

Interrupts 6 & 7 do not seem to have been broken out, physical pins 8 & 9. http://arduino.cc/en/uploads/Main/arduino-mega-schematic.pdf Perhaps solder little wires on and bring those to a connector. Update the pins_arduino.c so the software can use them.

That's what we really need - a software tool to let you select a processor, define the mapping you want the pins to have to real hardware, and let it create custom pins_arduino.c files. This is the 3rd time this month where that would have been handy now...

Interrupts 6 & 7 do not seem to have been broken out,

And that's a mind-boggling design decision in itself. The two pins are unconnected, just waving in the breeze.

I would also say you can use the Rx pin as you describe.


Rob