In SX Microcontrollers, SX/B Compiler and SX-Key Tool, vchaney wrote: Please, I need some help in the use of asynchronous interrupts. I have two balls running down a track right-to-left, and as they enter a tunnel they run across a ballComing switch RB.0, which triggers an interrupt when it connects to ground. Then, a pattern of LEDs follows the balls as they go through the tunnel. The balls are not always the same distance apart, so the second ball needs to trigger the interupt, too, so that each ball has a pattern of lights following it. If there is no second ball (or the second ball is far enough behind), the pattern just follows the one ball. Here is my problem. There are light patterns that are stepped from a position to the right and then back one position at a time until they are centered, and then they are stepped left one position at a time until the pattern is gone out the left side of the tunnel. Then it looks like the light pattern enters the tunnel on the right, and follows the ball through the tunnel until it runs out the left end. The switch triggers the interrupt to get the process started, and this works fine. Then there is a section of the program where an interrupt (for the second ball) should create a second light pattern overlapping the first light pattern, but this does not happen. Then there is a section almost identical to the first non-functioning section, and it works fine. The only difference is in which direction the pattern is being moved. The code which is detecting the interrupt is the same. Why won't the interrupt get detected on the first half of the light pattern's journey, and yet get detected just fine on the second half of it? As it is, my program works if the second ball is not following too close, but if it is close then the switch gets hit during the part of the program that is not detecting the switch, and I only get one pattern of lights as if there was only one ball. I have attached my code. The troublesome section has some comments that point out where the problem is. The patterns in each step are shifted out to MAX6969 chips (constant current LED drivers, each drives up to 16 LEDs, they are connected together so that the patterns for all four sets of LEDs are shifted out all at once). The interrupt routine just sets a flag (runFlag), and the program uses the flag's being set to decide that there are some balls with light patterns to be overlapped. There is so much of the program that works, I can't see why the one section isn't working. I have tried a zillion variations, and there is probably some simple thing that I am not doing right, but I sure can't find it. Thank you in advance for your help. Vic ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=412878 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)