|
|
View previous topic :: View next topic |
Author |
Message |
Bryan
Joined: 23 Apr 2005 Posts: 73
|
Sporadic Interrupts |
Posted: Sun Jul 10, 2005 12:19 pm |
|
|
My program uses external interrupts which are triggered by pushbuttons to toggle states. My particular application is designed to run longterm so it will be on for days, weeks, or even months. The problem I have been noticing is that sometimes I will toggle states but then after a few hours it will toggle itself back to the initial state automatically, almost as if the PIC is resetting (When I want it to remain in the toggled state permanently until the button is pressed again). I don't have a WDT or any other reset functions set up, so I'm not sure why this would be happening. Is there any chance it could be getting noise from somewhere and triggering the interrupt instead of resetting? My circuit is all in a breadboard with jumper wires going everywhere right now in a jumbled mess so that idea isn't far-fetched. Any ideas? Here is my setup code:
Code: |
#include <18F1320.h>
#device adc=10
#fuses NOWDT,NOPROTECT,NOLVP,NOMCLR,INTRC_IO
#use delay(clock=8000000)
#include "lcdporta.c"
|
|
|
|
valemike Guest
|
|
Posted: Sun Jul 10, 2005 1:27 pm |
|
|
So you're wondering if you're actually resetting or noise is causing the PIC to think there are button presses, and bringing you back to your initial state?
If you are conveniently hooked up to Hyperterminal, you can do a printf in one of your first instructions in main():
Code: |
void main(void)
{
initialize_ports();
printf ("PIC reset\r\n");
...
while (1)
{
state machine
}
}
|
Now if you run it today, and find yourself tomorrow sitting in the original state, look at your Hyperterminal dump and see if there are any additional "PIC reset" displays while you were gone.
If the PIC is not resetting then check for noise, do some really good software debouncing, and you might even need to put some better filtering (e.g. LC filters) at your inputs, depending on how noisy your circuit is. |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Sun Jul 10, 2005 1:30 pm |
|
|
If you think that noise is a problem, you can add a pull-down resistor to you interrupt line and/or put a 0.1uF cap from interrupt line to ground. The latter, though, will increase the rise time of your interuupt signal.
Nick |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sun Jul 10, 2005 4:58 pm |
|
|
Quote: |
My circuit is all in a breadboard with jumper wires going everywhere right now in a jumbled
mess so that idea isn't far-fetched. Any ideas?
|
Before start finding an intermitent long term code error, I would made a printed circuit
board with all the hardware soldered and following the rules of good art, using the
corresponding decoupling capacitors and so on.
This will save you to spend a lot of time following a non safe contact like a breadboard jumper.
Best wishes,
Humberto |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|