What does 'debug' do?

John O

Senior Member
I've got a mystery with the 'debug' command!

Admittedly, I'm not using a "standard issue" serial LCD display but I still can't fathom what's happening here. It is a serial LCD with the same basic dispaly module as the standard issue one.

This code (the part between init and main just initializes the display)....
Code:
init:
  hsersetup B9600_4, %10000 	;Use LCD Pin 1, no hserin 
  hserout 0, (13) : pause 100 	;Initialize LCD
  hserout 0, (13) : pause 100
  hserout 0, (13) : pause 100
  pause 500
  hserout 0, ("ac1", 13)  		;Clear display
  pause 50                				
 
 main:
   b0 = "A"

   debug				;Position 1

   hserout 0, ("ac80", 13)		;Cursor to top corner (ac80 )
   hserout 0, ("ad", b0, 13)             ;Display data  (ad{data} )
  
  ; debug 				;Position 2

   pause 250
   goto main
.... displays a letter 'A' at the top of the LCD as expected:


But, if the debug command is moved to 'Position 2'.......
Code:
init:
  hsersetup B9600_4, %10000 	;Use LCD Pin 1, no hserin 
  hserout 0, (13) : pause 100 	;Initialize LCD
  hserout 0, (13) : pause 100
  hserout 0, (13) : pause 100
  pause 500
  hserout 0, ("ac1", 13)  		;Clear display
  pause 50                				
 
 main:
   b0 = "A"

   ; debug				;Position 1

   hserout 0, ("ac80", 13)		;Cursor to top corner (ac80 )
   hserout 0, ("ad", b0, 13)             ;Display data  (ad{data} )
  
   debug 				;Position 2

   pause 250
   goto main
.... the cursor-positioning command to the LCD (ac80) is ignored after the first time round the loop and gets printed as data instead:


The mystery (to me anyway!) is what is the debug command doing positioned after the hserout that it doesn't do before it and why is it affecting hserout anyway?

John.
 

Technical

Technical Support
Staff member
As the hserout is a 'background' processing module, it may be that the debug gets processed before the CR of the last hserout has finished transmitting. Debug switches off background processing, so may cause the corruption of the last character. In this case the LCD will not see a 'complete' CR and get confused.

If this is the case a brief 'pause' before the debug should resolve it.
 

Andrew Cowan

Senior Member
I've used 'pause 0' before for really short pauses (for ignoring noise on an input).

The advantages of a non-optimising compiler :).
 

John O

Senior Member
My programming over recent years has all be 'event-driven' so this sequential stuff takes a bit of getting used to again. :)

In my code above, I actually had a 'pause 250' immediately before the jump to 'main' so the easiest thing was to swap the debug and the existing delay over!



John.
 
Top