Symbol Problem

CDRIVE

Senior Member
I'm working with the code below which works fine as it is. The last two arguments in the SerOut command translate as follows...
254 = Switch LCD to "Instruction Mode"
192 = Print the next Rx data to Line 2 starting at position 1.
I would like to replace 254, 192 with a Symbol (NewLine) but no matter how I've structured my code I either get a syntax error or it simply doesn't print to line 2. Before anyone replies with why not use "CrLF" the answer is simple. The LCD doesn't recognize that instruction. It has it's own instruction set, so 254,192 must be used.

Thanks,
Chris

Code:
;    Function: Tx serial data to MILFORD-2X16-BKP serial LCD       
;    Last Revision:
;    Target PICAXE: 08M2  
; *******************************
Main:
     Wait 1
      SerOut C.1,T2400,("Line Number 1", 254, 192)  ;Prints to Line 1
     Wait 1
      SerOut C.1,T2400,("Line number 2")    ; Prints to Line 2
End
 

Technical

Technical Support
Staff member
Use a preprocessor directive

#define

not

symbol =

for generic text substitution like this.
 

hippy

Ex-Staff (retired)
Staff member
It would possibly be better to define two items which put the OLED/LCD cursor at the start of line 1 or 2 rather than have a 'NewLine' which will not actually do as its name suggests ...

Code:
#Define Line1 254,128
#Define Line2 254,192

main:
  Wait 1
  SerOut C.1,T2400,(Line1, "Line Number 1")  ;Prints to Line 1
  Wait 1
  SerOut C.1,T2400,(Line2, "Line Number 2")  ;Prints to Line 2
  End
Note that there is no "=" in the #DEFINE defintion. If one is included it will be substituted into the SERTXD commands and will cause a syntax error.
 

CDRIVE

Senior Member
It would possibly be better to define two items which put the OLED/LCD cursor at the start of line 1 or 2 rather than have a 'NewLine' which will not actually do as its name suggests ...

Code:
#Define Line1 254,128
#Define Line2 254,192

main:
  Wait 1
  SerOut C.1,T2400,(Line1, "Line Number 1")  ;Prints to Line 1
  Wait 1
  SerOut C.1,T2400,(Line2, "Line Number 2")  ;Prints to Line 2
  End
Note that there is no "=" in the #DEFINE defintion. If one is included it will be substituted into the SERTXD commands and will cause a syntax error.
Unfortunately this didn't work for me. PE6 didn't object to anything but VSM upchucked on the SerOut line. VSM reported "Unrecognized Symbol .. "Line1". Same error was thrown for "Line2". I juggled the code around but to no avail.

I eventually went back to declaring Symbols with the following structure that both PE6 and VSM are happy with. I believe the problem was the "," being included in either the Symbol and the #Define declarations.

Code:
Symbol Cmd = 254
Symbol Line1 = 128
Symbol Line2 = 192

Main:

    SerOut C.1, T2400, ("Line Number 1", Cmd, Line2)
    SerOut C.1, T2400, ("Line Number 2")
End
Splitting the Command mode value (254) and actual command value (192) works perfectly. It eliminates the comma issue. It also gives me latitude to shuffle things around. As long as "Cmd" precedes the instruction value PE6 and VSM doesn't care if they're transmitted from a single SerOut command or on the next SerOut command.

Thanks,
Chris
 
Last edited:

hippy

Ex-Staff (retired)
Staff member
Unfortunately this didn't work for me. PE6 didn't object to anything but VSM upchucked on the SerOut line. VSM reported "Unrecognized Symbol .. "Line1". Same error was thrown for "Line2".
That would be expected; #DEFINE is handled by the pre-processor rather than the compilers, the pre-processor is only supported by PE6.
 

CDRIVE

Senior Member
That would be expected; #DEFINE is handled by the pre-processor rather than the compilers, the pre-processor is only supported by PE6.
Thanks for the explanation. So if I understand you correctly the #DEFINE as you structured it (including the comma separator) would have worked on a live chip?

Chris
 

hippy

Ex-Staff (retired)
Staff member
Yes, that would have worked on a live chip if downloaded using PE6.

It can be seen working in simulation under PE6; the 254,128 will appear as [F0][80] and 254,192 as [F0][C0] in the Terminal window. Those are the hex codes of the non-printable character bytes sent.
 
Top