Ok, this gave me a lot off headaches: I tried to use the Ring Interrupt on the fona – an advertised feature on the product page / spec sheet but with no, and as I found out misleading, doc. This is the journey to figuring out how to use this feature.
The spec states:
#7 – used as the FONA RI (ring interrupt) pin, you can use this to alert you when an SMS or phone call comes in
which is exactly what I need. The way the SIM800 typically works is, that when a call comes in it sends over it’s serial a message like
which tells us who’s calling. The problem is we would need to constantly poll the SIM800’s serial and see what messages are there an if one of them contains the string “+CLIP…”. Bad idea!
Luckily there’s an interrupt on Pin#7 for this. Unfortunately Pin#7 doesn’t exists. So let’s figure out this whole numbering scheme and see if we can find the mysterious pin. Let’s gather some intel.
Atmel states that the 32u4 has 13 external interrupts. Clearly our Fona does not have 13 dedicated interrupt pins. Looking at the Arduino Leonardo which has the same 32u4 chip we see that this unit has 5 of these 13 irqs on external pins. Since the feather is halfway arduino compatible this could also be the case on our Feather. The spec states 4 IRQs, and but all are mapped to other pins, namely:
#0 RX IRQ2
#1 TX IRQ3
#2 SDA IRQ1
#3 SCL IRQ0
A quick test shows that at least #0 is properly mapped according to the feather doc, so I assume this also goes for the others.
Looking at the schematic we can further confirm this. And while we’re in the schematic we can see that Pin#1 of the Atmel connects to Pin#68 of the SIM800 and these are labeled with our mysterious Pin#7. So what’s Pin#1(AVR) really? Schematic says PE6(Int.6/AIN0).
Well, I don’t trust adafruit in this regard and INT.6 with the dot does not comply to the naming conventions on the other interrupts. So a look in the spec sheet of the 32u4 reveals, that Pin#1(in avr terms) is really interrupt#6 (I couldn’t figure out where Int#5 is, but thats not of our concern).
So give INT#6 a try… nothing.
Now it’s getting tedious… let’s look at the source code of attachInterrupt in hardware/arduino/avr/cores/arduino/WInterrupts.c and take a deep breath. Without trying to reproduce everything that goes on here there are some interesting bits that caught my eye: EXTERNAL_NUM_INTERRUPTS is obviously the number of external interrupts for the currently configured board. Since I can’t figure out such an easy task as to where on earth the downloaded board config for the Feather 32u4 is stored we just run a sketch and print this.
The other interessting thing is: when attaching IRQ#4 on a 32u4 chip INT6 is shifted in some interrupt control register. Since we’re looking for INT6 this seems to be an awkward but promising candidate.
case 4: EICRB = (EICRB & ~((1<<ISC60) | (1<<ISC61))) | (mode << ISC60); EIMSK |= (1<<INT6); break;
Ok, printing EXTERNAL_NUM_INTERRUPTS does not work out of the box but just specifying IRQ4 as the Ring_Interrupt in the IncomingCall example of the Fona produces the following output:
FONA is OK ---> AT+CLIP=1 <--- OK Caller id notification enabled. PINGPINGPINGPINGPING> Incoming call... Phone Number: +CLIP: "491234562341",145,"",0,"",0 RING! Phone Number: 491234562341 PINGPINGPINGPING
(The PINGPING is a keep alive I inserted to see if the Fona is still alive).
So how does this relate to the Fona specs&docs? No mention of a 5th (IRQ#4) interrupt on the board. No Pin#7 on the board but in the doc. No relation between Atmels INT6 and arduino’s INT4 numbering scheme.
3 effing hours for such a braindead task!
Does no one use the RI which is clearly advertised as one of the features on the Spec-Sheet? Does no one care? Geez… back to some serious work. 😐