chipKIT® Development Platform

Inspired by Arduino™

External Interrupt Not working if you run Wire.begin()

Created Tue, 05 Jun 2012 18:13:11 +0000 by kmansfie


kmansfie

Tue, 05 Jun 2012 18:13:11 +0000

I have been working with MPIDE for a few weeks now. I have been working on a device to measure liquid flow. This is my first experience with the Max32. There are a few features that I'm using. I have a Max32 board with the Ethernet Shield attached. I also have an NKC display with a few hardware modifications to the display so that it will work with the Max32. All of those items work great. My problem is in the title. When I run Wire.begin() my external interrupts no longer work. I have a very small sketch that shows this problem. I can post this sketch if you would like.

I am running the latest release mpide-0023-windows-20111221 on a Windows 7 64 bit machine. I have also tried the latest test release hoping that this problem was fixed in it (mpide-0023-windows-20120603-test) but, the problem is also in that release. I have also tried demolishun's WInterrupt.c fixes but that still has the same problem.

Any help or pointers where to look would be greatly appreciated.

Kim KMI Technology


kmansfie

Wed, 06 Jun 2012 00:36:50 +0000

Solved!!

I actually figured out what was wrong. I used the instructions that KeithV posted on the Forum for using MPLAB to debug sketches . Good job Keith! The instructions are great and easy to follow and they work. I did run into a couple of issues that took some work to get around and I'll post those in the debug thread.

One of my pet peeves about this system is the stacking of boards and the use of pins. My problem was I was trying to use external interrupt 4 and what I found out was that that pin was being reallocated by the wire module to communicate with the EEPROM on the Ethernet Shield I believe. This prevented that pin from being used as an external interrupt. I looked at the documentation on the Ethernet Shield and that pin isn't talked about in the table of used pins. Probably an over site. It is difficult to stack more than two boards together and have them work. I was able to move my external interrupt to INT2 which is pin 7 and that worked. So, for now that problem is fixed and I'm moving forward again.

Kim KMI Technology


Jacob Christ

Tue, 26 Jun 2012 14:13:37 +0000

This topic looks like its related to this topic:

http://www.chipkit.org/forum/viewtopic.php?f=18&t=1391

So you say INT4/RA15 (uCpin 67) is not working. From my prospective this pin should not be used by Ethernet. If it is, I think it is in error.

It appears that the chipKIT Ethernet code is quite hobbled together.

Jacob


GeneApperson

Tue, 26 Jun 2012 21:31:45 +0000

The ethernet library doesn't use INT3 or INT4. The problem is that the PIC32 microcontroller pins 66 and 67 share SCL1 with INT3 and SDA1 wsith INT4. You can't use INT3 or INT4 if you are doing I2C using the wire library.

The Network Shield reference manual fails to mention this detail of the PIC32 microcontroller.

Gene Apperson Digilent


GeneApperson

Tue, 26 Jun 2012 21:39:00 +0000

This is documented in the Max32 reference manual. The I2C section on page 9 says that pin 20 is SCL and pin 21 is SDA. The External Interrupts section says that pin 20 is INT4 and pin 21 is INT3.

Granted... this is pretty obscure, but it's not clear to me what would be a good way to document all of the potentially conflicting uses of the pins on the microcontroller and how that might affect different libraries for different shields.

When I have some spare time ;) I'll see if I can improve the documentation a bit.

Gene Apperson Digilent


GeneApperson

Tue, 26 Jun 2012 21:43:18 +0000

I looked at the documentation on the Ethernet Shield and that pin isn't talked about in the table of used pins. Probably an over site.

Definitely an oversight, and one that I can fix by adding a 'Pins Used by I2C Interfaces' table to the document.

Sorry about that.

Gene Apperson Digilent


Jacob Christ

Tue, 26 Jun 2012 21:46:42 +0000

Granted... this is pretty obscure, but it's not clear to me what would be a good way to document all of the potentially conflicting uses of the pins on the microcontroller and how that might affect different libraries for different shields.

This would be a 4+ dimensional chart. Board X, Pin Y, Library Z[n], Shield A[m]....

For me, I just look at the schematic for the shield and expect pins going to the chip I'm using are used by the library.

Jacob


PICedh

Thu, 04 Apr 2013 21:39:59 +0000

Hello.

I reopen this topic because I have just received a MAX32 and I have also discovered these issues about interrupts.

I used to work with UNO since a long time and I was able to use I2c AND 4 external interrupts. I was very sad to discover that on MAX32, 2 external interrupts are lost if you use I2c. Is there any solution ? Can we use other pins for I2c, I see SDA2/SCL2 pins ?

I need 2 interrupts fro 2 wheel encoders and one more fore the WIFI shield

In addition, please note this error in the MAX32 reference document page 10: The CAN2 interface uses the following pins: Pin 23 (AC2RX), [color=#FF0000]Pin 21[/color] (AC2TX).

>>>>it is not pin 21 but pin 22

And also, the pin related to the MAX32 connection described in the WIFI shield reference document are wrong