Wednesday, March 6, 2019

Unintended Interrupt

Most of the time spent on a hardware project is solving problems. I ran into an interesting one on my Arduino Nano: sending a digital out high on one pin was causing the hardware interrupt on another pin to trigger. What? Turns out my test setup was causing the problem. A bad case of the observer effect.

The Nano is biased at 5 V, which makes it easy to interface to the Atari. However, my FPGA-based logic analyzer is only 3.3 V compliant, so I need a level translator in between. I'm using a small 4-bit translator based on a single-FET design. These are often used with I2C interfaces. 

I was stumped by the false interrupts and couldn't find anything like it online. It drove me to read the Atmega 328 data sheet. At least I have a better understanding of the microcontroller and its interrupts. I finally went back to something I knew worked: turn the on-board LED on and off using an external interrupt. I then started changing the output pin #, which worked until it landed on the one I was monitoring with the logic analyzer. Ack! Grasping at straws, I tried adding pull up and pull down resistors to no avail. Then I realized the false interrupts only occurred when the output changed from low to high.

Maybe translator was sinking or sourcing too much current on the Nano's push-pull output drive? The typical diagram I see with these translators show effectively open drain outputs, so maybe I'm not using it in its intended application. It also turns out these things pull current when the signal is low. I think that suddenly applying a high causes the translator to load down the output with too much current, causing a malfunction on the IO bus.

I fixed it by putting a 330-ohm resistor in series between the output and the translator.

Whew.


No comments:

Post a Comment