I'm using Arduino UNO and I have a simple code that is supposed to function as a 6-bit counter clocked at approximately 100 kHz. PORTB pins serve as output for the counter bits.
When I run the code, PORTB outputs toggle perfectly at the desired frequency, however, every 15 seconds (or so), all the port outputs go LOW for a couple of seconds and then start toggling again. I cannot seem to explain this behavior. Am I missing out on something elementary. Thanks in advance.
Thanks for the reply. I tried making "i" a byte and it didn't help. In the meantime I also tried replacing delayMicroseconds() with a TIMER interrupt based program and the same problem persists.
@Keith: I tried doing that. I ran it with a Serial.println(i) at the end of the loop at 9600 baud. The PORTS worked fine albeit at a lower frequency (120Hz only instead of 10kHz). i seemed to be working fine, going from 0 to 63 and back to 0. I observed the output for about 5-6 minutes and the ports didn't go low this time. The problem mysteriously solved itself.
But when I reverted back to my original code without the serial printing, the problem reappeared.
@Mark: I did check the RESET line. it remains high through the entire code. It is probably not resetting itself. I did try disablign the auto-reset function to no avail.
Also, I tried using a Duemilanove to run the same code and even that gives the problem. Can it be some sort of WATCHDOG TIMER or something? I'm completely stumped.
Okay!!! I seemed to have figured out the issue. I think there was some kind of power issue with my USB, so it was doign a Brownout reset perhaps. When I ran the same code on a different PC it worked. So I decided to supply UNO from VIN pins and it worked. The PORTs work as expected without going low.
Surprisingly nothing. The outputs of the PORT go to a bunch of capacitive transmitter electrodes. So the current drawn would be extremely low. And at the time of posting the problem, the Arduino wasn't even connected to the system.