Problem with "RUN"...
04A236
Posts: 18
Hi all,
I'm trying detect some pins from different program slots...
each detection should be independent from one another...
but from the manual, it says that:
How do I reset conditions of pins when in a new program slot?
I've tried manually setting the value of pins to as expected...
but my debug shows otherwise...
Please HELP!!
Thanks in advance,
Rita
·
I'm trying detect some pins from different program slots...
each detection should be independent from one another...
but from the manual, it says that:
The I/O pins retain their current state (directions and output latches) and all Variable and Scratch Pad RAM locations retain their current data during a transition between programs with the RUN command.
How do I reset conditions of pins when in a new program slot?
I've tried manually setting the value of pins to as expected...
but my debug shows otherwise...
Please HELP!!
Thanks in advance,
Rita
·
Comments
DIRS = $00
OUTS = $00
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
You have been a great help...
the DIRS= $00 solved the problem...
Post Edited (04A236) : 11/16/2004 1:50:36 PM GMT
The order, type and size of all your variables MUST be IDENTICAL in all of the program slots, regardless of whether they are used in that slot or not. If they aren't, all sorts of strange errors which look like uninitialized or incorrect values may appear. The PBASIC Stamp Manual explains this in detail.
Regards,
Bruce Bates
does it matter if my variables in each slot are independent?
because each slot has their own variable...
please advice...
I'm not sure I uderstand what you mean by "independent". All varioable in all slots share the same memory. The reference to each variable within each slot is positionally DEPENDENT.
You might add variables in progam slot two which don't exist in program slot one, but they MUST be added at the end of all the allocations of the variables which exist in program slot one. So too with program slots three and higher, using the same technique.
The manual, which is free for the download, is much better at explaining this by the use of examples. The space here on the forum is limited. Please read the manual for further details on: program slots, declaring variables in program slots, and how they are used.
Regards,
Bruce Bates
must be the SAME in each slot and in EXACTLY the same order.· Constants and variables are read according to their position in the list.· If you add one variable at the end of the list on Bank0 and another variable at the end of the list in Bank 3, Stamp will read the variable called by the slot that uses it but it may read the value of the variable in the other slot.
To be certain, organize all you pin assignments, constants and variables in Bank 0, then copy and paste the whole thing to all the other slots.· This way you are safe.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
New Combo LCD Backpack
http://hometown.aol.com/newzed/index.html
·
I think you're referring to this sentence (on page 270 of the manual v2.0c)??
my independent means that variable in one slot (may be slot 0) has no relation to another slot (may be slot 1)...
the problem i had was this...· when running slot 1,·values from slot 0 of the same variable is forwarded to slot 1 through pin detection (latched as mentioned below on the same page)... which is not as what i wanted...
solution provided by Jon Williams does the trick of resetting all ports...
When using a particular data from another slot...··I used the·"STORE" command (page 323)...
I'm still learning and trying to grasp a hold of the coding...
Please advise if i have misunderstood the text...
The reason why i'm so concerned is that...· i'm running out of memory space for variable allocation...· that's why i can't afford to have exactly the same variables throughout all program slots...·
Thank you so much for your feedback...
Regards,
Rita
OR....use a RAM table to store varibles then use GET/PUT. Be careful GETing and PUTing WORD vars.
I have a datalogger running in a testing environment and it uses multiple program slots, switching every second. It does NOT have the same variables declared in each slot but it does run quite well.
The trick I use is that I copy crucial variables to the scratchpad RAM (PUT) before switching to an other slot and I reload them (GET) at first when I reenter the program slot.
It seems to work in my situation.......
Klaus
PS this thing is still under development so the code has not matured yet
The solution Jon supplied has solved my problem...
·Thanks!!
Regards
Rita