Hi all, This is a general use question. I have an app. that is using an Uno, and at times a Teensy+2. I don't use interrupts. I see random stalls in the app. over periods of a few hours to a day or two. There are many causes I have ruled out. The processors have interrupt enable registers that I am not using, that is I never explicitly enable an interrupt input.
Question: Do libraries like Serial and I2C enable all interrupt inputs ? Is it possible that this is the case and if one were to leave the two external interrupt pins floating, even though not in use, that a static induced pull down on those INTx pins could vector a program into the either ?
I have recently explicitly pulled those pins to a high state with the processor internal pullups. I have no run the app. continuously for 5 days with no failures. This appears to have solved this issue but I ask the question as I need to know the root cause to be certain all is good.
attachInterrupt() and detachInterrupt() do the right thing about enabling/disabling
the relevant interrupts, so if you don't call attachInterrupt or write to the interrupt
mask registers it can't be that.
Also I presume you are not using pin-change interrupts either - in which case
those interrupts won't be enabled either.
The HardwareSerial library uses interrupts from the UART, I presume you
are using standard Arduino boards which have physical pull-up resistors on
RX and TX pins though.
Without seeing your code there's not much else to say - you've checked you're not
short of RAM?
Thanks MarkT,
Your sentence "attachInterrupt() and detachInterrupt() do the right thing about enabling/disabling
the relevant interrupts" explains what I need to know. Memory - I should have plenty and have been putting in tests to see if I am over running the available space, as yet I don't see an issue. If I can arrive at a code snippet that reduces the problem to something not too large to post I will put that up.
I am using both standard Arduino HW as well as a Teensy++2. The later running a larger code sequence.
brianb00:
Question: Do libraries like Serial and I2C enable all interrupt inputs ?
I hope not.
(Why would they?)
brianb00:
I have recently explicitly pulled those pins to a high state with the processor internal pullups. I have no run the app. continuously for 5 days with no failures. This appears to have solved this issue...
If that really fixed it then you might have power supply issues. Unconnected input pins can cause the input transistors to rapidly toggle high/low and this causes internal power fluctuations. See section 13.2.6 of the Mega328 datasheet ("Unconnected Pins").
brianb00:
but I ask the question as I need to know the root cause to be certain all is good.
It's very easy to look at the registers and see what interrupts are enabled.
Could there be nearby circuits with large currents being switched? If so add a 1k resistor
from RESET to Vcc to stiffen it up against noise spikes perhaps? Keep the leads short
though or you risk adding to noise pickup.