I am working on a project with Arduino Due and I have to use interrupts. The problem is that each time code runs there comes a stray interrupt on one of the pins. Actually the code was very long and it took me several hours to find this bug. So i wrote a separate piece of code to test it. Here it is:
Now the problem here is that each time the cpu resets there is a stray interrupt on pin 7. I have tried several options: changing the pin, using delays, disabling the interrupts in setup and enabling them after a while.... with no avail.
In the end I had to use a flag to ignore the first stray interrupt. Still I want to know what is the problem with my code. Note that i have to set the debouncing filter for the pins (nescessity of my project).
techtweektweek:
I have removed the Serial.print but the problem still persists. Could it be a problem with my board?? I have used it pretty roughly.
Please describe in as much detail as possible how the problem manifests itself with the code in Reply #3 - what actually happens and what should happen?
For those of us unfamiliar with a DUE, what do these lines do? - in a little more detail than your comments
REG_PIOC_WPMR=0x50494F00;
REG_PIOC_DIFSR=0x01800000; //ebounce filter is enabled
REG_PIOC_SCDR=1600; //set debounce time
REG_PIOC_PUER=0x07800000; //pins 6,7 are pulled up
REG_PIOC_IFER=0x01800000;
One of the joys (?) of using interrupts is that you never know if they know more than you do.