PDA

View Full Version : BS2e reset issue



Wayne P.
08-09-2005, 11:25 PM
Please advise me on what might be causing my BS2e to intermittently reset all by itself. (?)

I've written all the $PBASIC 2 code, which includes multiple programs in individual EEPROM program slots of the BS2e.
(Therefore I've incorporated the 'RUN' command)

When I power-up my BS2e hardware the microcontroller obviously initiates the slot 0 program first. In my application, slot 0 is used for initializing some 'user preset' registers before starting the actual 'system code'. (The 'system code' as I call it, is the program code that will continually cycle, non-stop after the user initialization is performed at power-up. This cyclical 'system code' starts in slot 1)

Once all the user presets are entered, via external switch closures on INPUT lines of the BS2e, then I initiate a 'RUN 1' command to jump over to the slot 1 program. NOWHERE IN MY CODE, IN ANY PROGRAM SLOT, DO I HAVE THE·'RUN 0' COMMAND THAT WOULD REINTRODUCE THE INITIALIZATION MODE. (This action would obviously act the same as a power-up or system reset.....most undesirable in my application)

Yet, very intermittantly (a few times now) after running properly, my program automatically finds it's way back to the initialization mode waiting for the user to make his pre-set selections (?) I've ensured a stable, well regulated +5Vdc on Vcc and also a HI on pin 22 'Reset' via an external 47k pull-up resistor to +5V.

1. I know that a power disturbance could cause this problem. (An intermittent +5V·on Vcc pin 21 perhaps)

2. I know that pulling pin 22 low (reset) could also cause this. (I do have a momentary switch on pin 22 but no one is touching this button and the PCB trace at pin 22 is clear of debris to ground. (solder flux)

3. I know that a 'RUN 0' in my code will cause this problem.

What possible conditions (other than the two I mentioned above) could cause the BS2e to run the slot 0 code after leaving to another slot? (I've tried to recreate this reset fault by pressing all the switches at once, (keypad bashing) or in specific switch combinations, to simulate a possible 'finger fault' that might be confusing the BS2e......no such luck yet in manually initiating the problem)

Finally, could noise coming into the 'Serial In' or 'ATN' pin of the stamp cause my problem? I only suggest this because I·have noticed that if I leave my stamp project·powered & connected to my PC (RS232 port) and I then·reboot my PC, the stamp hardware reboots. It doesn't erase the program code...it simply resets my hardware thus·simulating the problem.

Thanks

Chris Savage
08-09-2005, 11:40 PM
Wayne,

·· It sounds like you already found one possible cause of the Stamp resetting...The PC being reset, or running any program which accesses the Serial Port and toggles the DTR line.· Does you Stamp Module switch any higher power loads, such as relays or solenoids?· You could be experiencing brown-out.· You could be generating EMI that could also contribute to a reset.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

Wayne P.
08-10-2005, 12:58 AM
Chris,

There is no question that rebooting my PC results in a resetting of the Stamp. (I do reboot my PC quite a bit as I have a dual-boot system running 2 different O.S.)

However please keep in mind...my problem of 'intermittent reset' of the Stamp happens when my Stamp hardware sits alone from my PC! (NO RS-232 serial connection to each other)

To answer your questions...
No, my project does not switch any high power loads. (I'm essentially only driving 7-segment LED arrays) My project does have a well regulated PSU converting 120Vac to 5.5Vdc and a provision for running off of an external +12Vdc battery.

Two last questions for you...
1. Is 'ATN' (pin#3) on the BS2e an input to the Stamp or an output from the Stamp?

2. Is my 47k ohm pull-up resistor required on the 'Reset' (pin#22)? Again, I do have a N.O. momentary switch here to ground for resetting when I occasionally require.

Thanks for your time,

Chris Savage
08-10-2005, 01:06 AM
Wayne,

·· ATN is an input, whose level is the opposite of the Reset line.· A high on the ATN line with bring Reset low, resetting the Stamp Module.· As for a pull-up resistor on the Reset line, you don't need it, it's internally pulled-up.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

southernbob
08-10-2005, 04:01 AM
This is probably not your problem, but it is something to check. This from the Basic Stamp

help file for RETURN:

RETURN sends the program back to the address (instruction) immediately following the most recent GOSUB. If RETURN is executed without a prior GOSUB, the BASIC Stamp will return to the first executable line of the program; usually resulting in a logical bug in the code. See the GOSUB command for more information.

I had a similiar problem awhile back when I tried shortening some code. The GOSUB and the

RETURNS matched up (pretty sure) but everytime I went to that particular subrtn

it did a 'soft reset' back to the start of the program. Never did figure out what the problem

was and went back to the original code to save my sanity.

Bob

Wayne P.
08-11-2005, 03:34 AM
Hey Bob, I think you might be onto something with my BS2e reset issue.

Following your lead·I did alittle more reading about the RETURN, GOTO & GOSUB commands from the 'BASIC Stamp Syntax and Refernece Manual'.....you know..."when all else fails read the manual".

From this read I've discovered something new and probably unrelated. (New to me anyway)

What's with the use of colons (:) after a label?·The manual states the colon is to be·used after a label but is not required on the reference to the label. (?) see example...

line#1· ·Start:
line#2··· ··DEBUG "Hi", CR
line#3·· GOTO Start

Line#1 uses the colon after the label named "Start".
Line#3 does not require the colon as it is a reference to the label.

I've never used the colon (:) after a label. Am I asking for trouble?

Thanks.

P.S. Bob, I'll let you know if I find anything conclusive regarding the reset issue.

Paul Baker
08-11-2005, 04:17 AM
Wayne P. said...

I've never used the colon (:) after a label. Am I asking for trouble?


Probably, the manual clearly states that Labels when declared require a colon after it. Labels when used do not require the colon, because it isn't being declared (created), only used. While it may be possible that your program works without the colon, following the advice of the manual is always in your best interest.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10