Author Topic: Moteino Mega -- pin change interrupts  (Read 6553 times)

jrdoner

  • NewMember
  • *
  • Posts: 34
Moteino Mega -- pin change interrupts
« on: October 13, 2015, 11:21:48 PM »
I just posted because I couldn't get SoftwareSerial working between a Nano and the Mote Mega.  I did put in a voltage divider as suggested.  Still no cigar, so I looked around a bit and discovered that the Arduino Software Serial Library requires that the Rx pin must be capable of pin change interrupt.  So I downloaded the Atmega 1284 data sheet, and found that it supports pin change interrupts on 4 pins.  But I can't be sure about the pin mapping of the 1284 pins to the Mote Mage.

So the question is -- in the pin map of the Mote Mega, which of the pins support pin change interrupt?

Boy, sometimes simple things can get so complicated!

Thanks in advance for any help.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino Mega -- pin change interrupts
« Reply #1 on: October 14, 2015, 01:25:38 AM »
I just posted because I couldn't get SoftwareSerial working between a Nano and the Mote Mega.  I did put in a voltage divider as suggested.  Still no cigar, so I looked around a bit and discovered that the Arduino Software Serial Library requires that the Rx pin must be capable of pin change interrupt.  So I downloaded the Atmega 1284 data sheet, and found that it supports pin change interrupts on 4 pins.  But I can't be sure about the pin mapping of the 1284 pins to the Mote Mage.

So the question is -- in the pin map of the Mote Mega, which of the pins support pin change interrupt?

Boy, sometimes simple things can get so complicated!

Thanks in advance for any help.
ok, we need to step back a bit from this and think about what you are trying to do.

1. The Mega has TWO hardware serial ports so you don't need SW serial on the Mega side of the link (unless you're not telling us everything you're trying to do).
2. On the Nano side of the link, if you want to keep the HW serial link for IDE support, then, yes, you do need SW serial library on THAT side of the link.  But that side only and there is no issue with pinChange interrupt on that device.

Having said that, there has been some good progress (see EnableInterrupt library) made supporting pin change interrupt for the Mega, but, frankly, I don't think you need this.

Tom

jrdoner

  • NewMember
  • *
  • Posts: 34
Re: Moteino Mega -- pin change interrupts
« Reply #2 on: October 14, 2015, 10:16:04 AM »
As it stands, the Mote mega has three hardware interrupts.  One of those is associated with the radio.  I have a real-time clock in my project that needs to interrupt the Mega, so that uses up one of the remaining two interrupts, and puts Serial1 out of the picture.  Serial0 I wish to retain for communication with the computer.  That's why I need a pin change interrupt.


TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino Mega -- pin change interrupts
« Reply #3 on: October 14, 2015, 10:38:18 AM »
As it stands, the Mote mega has three hardware interrupts.  One of those is associated with the radio.  I have a real-time clock in my project that needs to interrupt the Mega, so that uses up one of the remaining two interrupts, and puts Serial1 out of the picture.  Serial0 I wish to retain for communication with the computer.  That's why I need a pin change interrupt.
Ok, this makes sense now.  I didn't understand that you needed the interrupt for a device, I thought somehow you were using this for SW Serial.  Thanks for explaining.

Ok, well, you are in luck!  The EnableInterrupt library (https://github.com/GreyGnome/EnableInterrupt) now supports the Mega.  I was able to successfully build a test sketch that referenced the RFM69 library.   I will admit I didn't execute the code (I didn't have an appropriate setup or time to test) but I'm fairly certain this will work for you.

If you need a hand, let me know.

Tom

jrdoner

  • NewMember
  • *
  • Posts: 34
Re: Moteino Mega -- pin change interrupts
« Reply #4 on: October 14, 2015, 05:34:50 PM »
OK, thanks.   I was about to try setting up conversation between the two processors using I2C, something I haven't tried before.   But SW serial is something I know, so I'll try the library.

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino Mega -- pin change interrupts
« Reply #5 on: October 14, 2015, 05:58:19 PM »
OK, thanks.   I was about to try setting up conversation between the two processors using I2C, something I haven't tried before.   But SW serial is something I know, so I'll try the library.
Sorry, I'm not being clear.  With the EnableInterrupt library you can use virtually any pin for your RTC interrupt leaving the Serial 1 pins (which are HW serial) available for your application.  You do not need the SW serial library at all (at least on the Mega side of the link).

Tom

jrdoner

  • NewMember
  • *
  • Posts: 34
Re: Moteino Mega -- pin change interrupts
« Reply #6 on: October 14, 2015, 08:01:22 PM »
Right.  That makes the most sense.  Off I go.

JohnW

  • NewMember
  • *
  • Posts: 3
Re: Moteino Mega -- pin change interrupts
« Reply #7 on: November 17, 2015, 09:39:54 PM »
Hi guys, I'm new to this forum but have been reading this trail on PinChangeInterrupts for Moteino Mega with interest. Having need for some basic pushbutton  interrupts for my projects I decided to test out the GreyGnome EnableInterrupt library on the library's Simple example using a MoteinoMegas without radio and a pushbutton.

I was only partially successful, being able to run the Simple example successfully on pins 0 to 7, A0 to A7, and 10 and 11 ... but was unable to activate pin change interrupts on pins 12 through 23.

I was wondering if anyone else has used this library with a Moteinto Mega on these pins  since Mega1280p capability was added to EnableInterrupt in June of this year.


TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino Mega -- pin change interrupts
« Reply #8 on: November 18, 2015, 07:21:08 AM »
Hi guys, I'm new to this forum but have been reading this trail on PinChangeInterrupts for Moteino Mega with interest. Having need for some basic pushbutton  interrupts for my projects I decided to test out the GreyGnome EnableInterrupt library on the library's Simple example using a MoteinoMegas without radio and a pushbutton.

I was only partially successful, being able to run the Simple example successfully on pins 0 to 7, A0 to A7, and 10 and 11 ... but was unable to activate pin change interrupts on pins 12 through 23.

I was wondering if anyone else has used this library with a Moteinto Mega on these pins  since Mega1280p capability was added to EnableInterrupt in June of this year.
I would suggest contacting GreyGnome, he's pretty responsive.
Please post back here what you discover.

Tom

JohnW

  • NewMember
  • *
  • Posts: 3
Re: Moteino Mega -- pin change interrupts
« Reply #9 on: May 03, 2016, 05:52:17 PM »
I'm pleased to report that a major bug in EnableInterrupt library for 1284p  has just been resolved.  The library is now fully functional for 1284p processors. I have confirmed all pins on the MotetinoMega can now raise pin change interrupts.

This is a very nice library with very detailed documentation.  I highly recommend it.

You can find it on GitHub the author is known as GreyGnome.

John


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Moteino Mega -- pin change interrupts
« Reply #10 on: May 04, 2016, 09:51:37 AM »
Thanks for the update John,
I see his commit which fixes this has a define for MIGHTY1284, does that just work on a MoteinoMEGA? (ie not sure where MIGHTY1284 comes from but as I recall there's a board/bootloader by that name).

TomWS

  • Hero Member
  • *****
  • Posts: 1930
Re: Moteino Mega -- pin change interrupts
« Reply #11 on: May 04, 2016, 12:45:33 PM »
Thanks for the update John,
I see his commit which fixes this has a define for MIGHTY1284, does that just work on a MoteinoMEGA? (ie not sure where MIGHTY1284 comes from but as I recall there's a board/bootloader by that name).
IIRC MIGHTY1284 is defined somewhere in his include file after parsing all the potential 1284 implementations.  I worked with GreyGnome a while ago to make sure this worked with Moteino Mega.

Tom

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Moteino Mega -- pin change interrupts
« Reply #12 on: May 04, 2016, 02:14:16 PM »
IIRC MIGHTY1284 is defined somewhere in his include file after parsing all the potential 1284 implementations.  I worked with GreyGnome a while ago to make sure this worked with Moteino Mega.
Tom
Oh great, thanks Tom!

jra

  • Jr. Member
  • **
  • Posts: 81
  • Country: us
Re: Moteino Mega -- pin change interrupts
« Reply #13 on: May 04, 2016, 05:11:07 PM »
https://github.com/maniacbug/mighty-1284p started out as a early core supporting the 1284 on Arduino 1.0  The most recent incarnation supports a few more chips on Arduino 1.6.x https://github.com/MCUdude/MightyCore

JohnW

  • NewMember
  • *
  • Posts: 3
Re: Moteino Mega -- pin change interrupts
« Reply #14 on: May 05, 2016, 10:00:48 PM »
I only tested EnableInterrupt on the MoteinoMega. I believe the bug was isolated to the 1284p processor but the library does support an number of other boards.  I discovered that prior to the fix, only the Port A and B Pins as well as Pin 10 & 11 would raise interrupts using this library.