PDA

View Full Version : Debug Screen



Newzed
02-23-2005, 01:52 AM
I have a program that writes to an EEPROM.и Immediately before I write to EEPROM, the program goes to another bank to get the time so I can time-stamp each packet that is written to EEPROM.и This works fine with one exception -и each time the program returns with the time, the debug screen is cleared and I can only see the last packet entered.и Is there any way to avoid this "automatic" CLSing of the debug screen?

Here is the portion of the code in question:

main:
com = 2ииииииииииииииии 'go get time - returns to cont1
RUN 2
cont1:
HIGH grn
PAUSE 200
v1 = v1 + 1
v2 = v2 + 1

Thanks

Sid

Chris Savage
02-23-2005, 05:32 AM
Sid,

и First of all I think you are going to need more of the code to see what's going on.и There's no DEBUG statement in the sample you provided to see where that is even happening...

ии Second...Your code is not going to work as listed.и When you use RUN in a program, it does not return to the statement following the RUN command.и You get back to that bank via a RUN from the target bank, and that starts program execution at the beginning.



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--

Newzed
02-23-2005, 05:43 AM
Chris, I use flags when going between banks.и The flags take me directly to the specified lael in the target program.и For instance, at the very beginning of my program, I wrote:

init:
HIGH cs
HIGH reset
IF com = 1 THEN start
IF com = 2 THEN atdata
IF com = 3 THEN cont3

I wrote later in the program:

com = 2ииииииииииииииии 'go get time - returns to cont1
RUN 2

The program jumps to bank 2 and bank 2 says:

IF com = 1 THEN set1
IF com = 2 THEN readit1
IF com = 3 THEN timeit

and then readit1 says:

GOSUB getclk
com = 3
RUN 0

whcih takes me directly to cont1 to continue the program.

About the debug statements - I didn't feel they were necessary.и If I disable the "go get time" statements, all packets appear on the screen like always.и Only when the "go get time" statements is active does the screen CLS each time it displays a new packet.

Sid

Chris Savage
02-23-2005, 06:20 AM
Sid,

и Flags, huh?и Clever...Still the DEBUG statement is apparently what's causing your problem, so seeing the DEBUG statements themselves would seem to be the logical place to look.и The only thing I can think of without seeing them is that some value you are sending to the DEBUG screen isn't what you expect it to be, and the value is say an ASCII 12, which would clear the screen.



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--

Newzed
02-23-2005, 06:38 AM
Chir, I could post the whole code if you like, but remember, if I disable the jump to get the time, debug functions normally.и Even with the get time jump, debug displays correctly, except that it clears the screen before printing the next packet.и I don't think it will help but the code is attached.и You will note tht the clockA is a .bs2 file, but the directive has been changed.и All files run on my BS2P24.



Sid

Newzed
02-23-2005, 07:37 AM
I couldn't solve the problem so I worked around it.и Copied the "Getclk" routine from bank 2 into bank 0, disabled the jump to bank 2, and inserted

GOSUB getclk

Now everything works fine.и I would still like an answer to the CLSing problem if anybody has one.

Sid

Jon Williams
02-23-2005, 07:37 AM
If you're jumping between banks it's safer to pass a message via the Scratchpad. You can also simplify this bit of code:

IF com = 1 THEN set1
IF com = 2 THEN readit1
IF com = 3 THEN timeit

to:

BRANCH (com - 1), [Set1, ReadIt1, TimeIt]

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TXи USA

Tracy Allen
02-23-2005, 08:33 AM
Hi Sid,

Here are the first few statements in your clock slot:



Init: DirA = %0011
'OutA= %0111 ' Rst and Clk low

DEBUG CLS
' -----[ Main Code ]-------------------------------------------------------
IF com = 1 THEN set1
IF com = 2 THEN readit1
IF com = 3 THEN timeit
' ...snip




Could your mysterious clearing of the screen have anything to do with the DEBUG CLS statement on line 4?






Newzed said...
I have a program that writes to an EEPROM. Immediately before I write to EEPROM, the program goes to another bank to get the time so I can time-stamp each packet that is written to EEPROM. This works fine with one exception - each time the program returns with the time, the debug screen is cleared and I can only see the last packet entered. Is there any way to avoid this "automatic" CLSing of the debug screen?


Here is the portion of the code in question:



main:
com = 2 'go get time - returns to cont1
RUN 2


cont1:
HIGH grn
PAUSE 200
v1 = v1 + 1
v2 = v2 + 1



Thanks



Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Newzed
02-23-2005, 08:40 AM
Good catch, Tracy -и I missed that one.и I'll put the program back like it was and check it out.и I will let you know.

Sid

Chris Savage
02-23-2005, 09:57 AM
Ha!и See?и That's exactly why I asked you to put the entire code up!и Extra eyes can sometimes spot things you may overlook when working with the same code over and over.



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--

Chris Savage
02-23-2005, 10:46 AM
Sid,
ии As long as I already looked at that one segment of code, I will point out one more thing, although it's probably insignificant.


Start:
DEBUG CLS
tMode = T24Hr 'for 12 hr tMode = T12hr
DEBUG "Enter S to set clock, R to read time", CR
DEBUGIN com
IF com = "S" OR com = "s" THEN set1
IF com = "R" OR com = "r" THEN readit
set1:
DEBUG CLS
DEBUG "Enter Date", CR
<trimmed>

In this segment of code you are getting input from the DEBUGIN statement.и There is no trap for characters other than those you are testing for.и If the user inputs, for example, J, the set1 routine will still be executed.

In fact, you could just test for the "R" or "r" and anything else would execute the set1 routine, saving you a few bytes testing for the "S" or "s".и Just an observation.и I noticed it while looking for the rogue CLS statement...



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--==<{Chris}>==--

Newzed
02-23-2005, 09:20 PM
Tracy, that was the problem.и Chris called it a rogue CLS - how true!
Removed it and now everything works great.

Chris, I'll add the trap in the clock slot.и This was the first pass at the new program so I have a bit of tidying up to do.

Jon, on the BRANCH statement, I had that in at one time, then deleted it because one of the COM statements was deleted and the sequence was
1-3-4.и Will the BRANCH statement still work or will BRANCH be looking for
COM = 2.

Thanks to all - this somewhat ambitious project is about ready to fly.

Sid

Jon Williams
02-23-2005, 11:33 PM
You need to match the number of targets for BRANCH, if not contiguous you can "fix" with LOOKDOWN:

LOOKDOWN com, [1, 3, 4], com
BRANCH com, [Set1, ReadIt1, TimeIt]

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TXи USA