Menu

Compiler problem with GCB@Syn

2014-09-25
2015-06-09
  • Jack Hoffnung

    Jack Hoffnung - 2014-09-25
                I now use GCB@SYN almost exclusively, but when I compile a program  
                        by Thomas Henry (Two-Line-LCD.gcb, posted below), I get an error.
    
                First, the program:
    
                 ;Two-Line Serial Driver and Demonstration of LCD Features
                ;for the PIC12F683 (Great Cow Basic source).
                ;This Revision: 6/2/2013
                ;Thomas Henry
                ;Note: a 2 by 16 LCD is assumed.
                ;----- Configuration
                #chip 12F683,8          ;PIC12F683 running at 8 MHz
                #config mclr=off        ;reset handled internally
                #config osc=int         ;use internal clock
                ;----- Eeprom Data
                ; The following messages need to be burned
                ; into eeprom data. Copy and paste this block
                ; at the end of the assembler file, removing
                ; the semicolons, of course. Then assemble
                ; that file as usual to create the hex file.
                'ORG 0x2100
                'DE "First well show"
                'DE "this message.   "
                'DE "Then well blink"
                'DE "five times.     "
                'DE "Now lets pan   "
                'DE "left and right. "
                'DE "Watch the line  "
                'DE "cursor move.    "
                'DE "A block cursor  "
                'DE "is available.   "
                'DE "Next well scroll this long message as a continuous marquee in one line mode. "
                'DE "Characters: Bye!"
                'END
                ;----- Constants
                #define ser GPIO.0      ;shift register data on GP0, pin 7
                #define clk GPIO.1      ;shift register clock on GP1, pin 6
                ;Here are various LCD commands which can be used.
                ;These are the LCD commands for the HD44780 controller
                #define clrHome = 1     ;clear the display, home the cursor
                #define home    = 2     ;home the cursor only
                #define RtoL    = 4     ;print characters right to left
                #define insR    = 5     ;insert characters to right
                #define LtoR    = 6     ;print characters left to right
                #define insL    = 7     ;insert characters to left
                #define lcdOff  = 8     ;LCD screen off
                #define lcdOn   = 12    ;LCD screen on, no cursor
                #define curOff  = 12    ;an alias for the above
                #define block   = 13    ;LCD screen on, block cursor
                #define under   = 14    ;LCD screen on, underline cursor
                #define undblk  = 15    ;LCD screen on, blinking and underline cursor
                #define CLeft   = 16    ;cursor left
                #define CRight  = 20    ;cursor right
                #define panR    = 24    ;pan viewing window right
                #define panL    = 28    ;pan viewing window left
                #define bus4    = 32    ;4-bit data bus mode
                #define bus8    = 48    ;8-bit data bus mode
                #define mode1   = 32    ;one-line mode (alias)
                #define mode2   = 40    ;two-line mode
                #define line1   = 128   ;go to start of line 1
                #define line2   = 192   ;go to start of line 2
                ;----- Variables
                dim char, msn, lsn, index, i as byte
                ;----- Main Program
                dir GPIO 0b00000000     ;all output (only GP0 and GP1 used)
                init                    ;initialize the LCD display
                printMsg(0)             ;print first message
                wait 3 S                ;pause 3 seconds
                printMsg(2)             ;print next message
                wait 3 S                ;pause 3 seconds
                repeat 5                ;blink it five times
                  sendCmd(lcdOff)       ;display off
                  wait 500 mS           ;pause
                  sendCmd(lcdOn)        ;display on
                  wait 500 mS           ;pause
                end repeat
                wait 1 S                ;pause before next demo
                ;demonstrate panning
                printMsg(4)             ;print next message
                wait 3 S                ;pause 3 seconds
                repeat 16
                  sendCmd(panL)         ;pan left a step at a time
                  wait 300 mS           ;slow down to avoid blur
                end repeat
                repeat 16
                  sendCmd(panR)         ;then pan right
                  wait 300 mS
                end repeat
                wait 1 S                ;pause before next demo
                ;demonstrate moving the cursor
                printMsg(6)             ;print next message
                wait 3 S                ;pause 3 seconds
                doHome                  ;home cursor
                sendCmd(under)          ;choose underline cursor
                for i = 0 to 15         ;move cursor across first line
                  sendCmd(line1+i)
                  wait 200 mS
                next i
                for i = 0 to 15         ;move cursor across second line
                  sendCmd(line2+i)
                  wait 200 mS
                next i
                for i = 15 to 0 step -1 ;move cursor back over second line
                  sendCmd(line2+i)
                  wait 200 mS
                next i
                for i = 15 to 0 step -1 ;move cursor back over first line
                  sendCmd(line1+i)
                  wait 200 mS
                next i
                wait 3 S
                ;demonstrate blinking block cursor
                printMsg(8)             ;print next message
                doHome                  ;home the cursor
                sendCmd(block)          ;choose blinking block cursor
                wait 4 S                ;pause 4 seconds
                sendCmd(mode1)          ;change to one long line mode
                doHome                  ;home the cursor again
                sendCmd(curOff)         ;and disable it
                ;demonstrate scrolling a lengthy one-line marquee
                for i = 160 to 237      ;print next message
                  EPread i, char        ;fetch directly from eeprom
                  sendChr(char)
                next i
                wait 1 S
                doHome                  ;home cursor once more
                repeat 141              ;scroll message twice
                  sendCmd(panR)
                  wait 500 mS
                end repeat
                wait 2 S
                sendCmd(mode2)          ;change back to two line mode
                doClr                   ;clear the screen
                ;demonstrate all of the characters
                for i = 238 to 250      ;print next message
                  EPread i, char
                  sendChr(char)
                next i
                for i = 33 to 127       ;print first batch of ASCII characters
                  sendCmd(line1+12)     ;overwrite each character displayed
                  sendChr(i)            ;this is the ASCII code
                  wait 500 mS
                next i
                for i = 161 to 255      ;print next batch of ASCII characters
                  sendCmd(line1+12)
                  sendChr(i)
                  wait 500 mS
                next i
                ;say good-bye
                sendCmd(line2)
                for i = 250 to 253      ;print last message
                  EPread i, char
                  sendChr(char)
                next i
                ;----- Initialize the LCD on power-up or reset
                sub init
                  wait 200 mS                 ;let the LCD settle for 200 mSec
                  sendNib(bus8/16)            ;begin in 8-bit mode
                  wait 5 mS
                  sendNib(bus8/16)            ;send again
                  wait 100 uS
                  sendNib(bus8/16)            ;and once more
                  wait 100 uS
                  sendNib(bus4/16)            ;switch to 4-bit mode
                  wait 100 uS
                  sendCmd(mode2)              ;2-line mode and LCD off
                  wait 100 uS
                  doClr                       ;clear the screen
                  sendCmd(LtoR)               ;print left to right
                  wait 100 uS
                  sendCmd(lcdOn)              ;turn display on, no cursor
                  wait 100 uS
                end sub
                ;----- Send a Nibble to the LCD
                sub sendNib(in param as byte)
                  param = param | 0b01000000  ;set the Enable bit
                  repeat 8
                    rotate param left         ;shift bits in one at a time
                    ser = status.c            ;put the bit on serial input
                    pulseOut clk,2 uS         ;clock it in
                  end repeat
                  wait 5 uS                   ;wait for Enable to take effect
                  pulseOut clk, 2 uS          ;clear the shift register
                  pulseOut clk, 2 uS          ;and the output latches
                end sub
                ;----- Send a Command to the LCD
                ;To transmit a command, RS will already be low.
                sub sendCmd(in cmdP as byte)
                  msn = cmdP & 0b11110000     ;get high nibble
                  msn = msn/16                ;shift right four places
                  sendNib(msn)                ;send complete nibble
                  lsn = cmdP & 0b00001111     ;get low nibble
                  sendNib(lsn)                ;send complete nibble
                end sub
                ;----- Send a Character to the LCD
                ;To transmit a character, RS must be high
                sub sendChr(in charP as byte)
                  msn = charP & 0b11110000    ;get high nibble
                  msn = msn/16                ;shift right four places
                  msn = msn | 0b00010000      ;factor in RS
                  sendNib(msn)                ;send complete nibble
                  lsn = charP & 0b00001111    ;get low nibble
                  lsn = lsn | 0b00010000      ;factor in RS
                  sendNib(lsn)                ;send complete nibble
                end sub
                ;----- Clear the screen
                sub doClr
                  sendCmd(clrHome)
                  wait 5 mS                   ;this command takes extra time
                end sub
                ;----- Home the cursor
                sub doHome
                  sendCmd(home)
                  wait 5 mS                   ;and so does this one
                end sub
                ;----- Print a message to the LCD
                ;The parameter 'row' points to the start of the string.
                sub printMsg(in row as byte)
                  sendCmd(line1)              ;get set for first line
                  for i = 0 to 15
                    index = row*16+i
                    EPread index, char        ;fetch next character and
                    sendChr(char)             ;transmit to the LCD
                  next
                  sendCmd(line2)              ;get set for second line
                  for i = 0 to 15
                    index = (row+1)*16+i
                    EPread index, char        ;fetch next character and
                    sendChr(char)             ;transmit to the LCD
                  next
                end sub
    
                Here’s the body of the error:
    
                Two-Line-LCD.gcb   (117): Error:  Syntax Error
                Two-Line-LCD.gcb   (131): Error:  Syntax Error
                Two-Line-LCD.gcb   (147): Error:  Syntax Error
                Two-Line-LCD.gcb   (217): Error:  Syntax Error
                Two-Line-LCD.gcb   (223): Error:  Syntax Error
    
                All of the errors point to lines containing   EPread .
    
                 The .asm is created however, and when I copy the  EEPROM code (with the semicolons
                 removed) to the end of it (and save it), I use MPASM to make the .hex file, but it 
                 won’t due to errors:
    
                Message[302] C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 115 : Register in
                 operand not in bank 0.  Ensure that bank bits are correct.
                Error[122]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 350 : Illegal opcode (I)
                Error[122]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 402 : Illegal opcode (I)
                Error[122]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 474 : Illegal opcode (I)
                Message[302] C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 652 : Register in operand not in bank 0.  Ensure that bank bits are correct.
                Message[302] C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 660 : Register in operand not in bank 0.  Ensure that bank bits are correct.
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 686 : Symbol not previously defined (SysMultSub)
                Error[122]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 691 : Illegal opcode (INDEX)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 717 : Symbol not previously defined (SysMultSub)
                Error[122]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 722 : Illegal opcode (INDEX)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 746 : Symbol not previously defined (SysDivSub)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 779 : Symbol not previously defined (SysDivSub)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 852 : Symbol not previously defined (SYSBYTETEMPX)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 855 : Symbol not previously defined (SYSDIVLOOP)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 860 : Symbol not previously defined (SYSBYTETEMPA)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 862 : Symbol not previously defined (SYSBYTETEMPX)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 864 : Symbol not previously defined (SYSBYTETEMPB)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 866 : Symbol not previously defined (SYSBYTETEMPX)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 868 : Symbol not previously defined (SYSBYTETEMPA)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 874 : Symbol not previously defined (SYSBYTETEMPA)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 876 : Symbol not previously defined (SYSBYTETEMPB)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 878 : Symbol not previously defined (SYSBYTETEMPX)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 881 : Symbol not previously defined (SYSDIVLOOP)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 893 : Symbol not previously defined (SYSBYTETEMPX)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 896 : Symbol not previously defined (SYSBYTETEMPA)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 898 : Symbol not previously defined (SYSBYTETEMPB)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 900 : Symbol not previously defined (SYSBYTETEMPX)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 904 : Symbol not previously defined (SYSBYTETEMPB)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 908 : Symbol not previously defined (SYSBYTETEMPA)
                Error[113]   C:\PIC\PICSTUFF\LCDBACKPACK\CODE\TWO-LINE-LCD.ASM 910 : Symbol not previously defined (SYSBYTETEMPB)
    
                    I get the same result if create the .asm and .hex with GCbasic in one step.
    
                    Here’s the interesting part:  I can compile sucessfully with an older version
                        of GCbasic that I used with Texpad ,and MPASM will create the .hex file from 
                        that successfully.
    
                    Any help appreciated!
    
                    Jack Hoffnung
    
     
  • Anobium

    Anobium - 2014-09-26

    Jack - I can get the code to compile etc. So, I am puzzled.

    Where is the original posting as I cannot emulate here as I am not aware of the hardware configuration from this posting.

     
  • Jack Hoffnung

    Jack Hoffnung - 2014-09-27

    Anobium,
    Thanks so much for your reply. The hardware (and software) is from an article written by Thomas Henry in Nuts & Volts magazine, February 2014. The hardware is comprised of a parallel 2 x 16 LCD, a shift register, and a few other components. It is configured such that only 2 inputs are needed from the PIC, clock and data. The software was obtained from a link in the article, and is the code I sent in my prior post. As I noted, it compiles without error in an older version of GCbasic, but with errors from within GCB@SYN, although the .asm is created. However, that .asm file will not assemble.
    Thanks again for your help with this.

     
    • Anobium

      Anobium - 2014-09-28

      Is this the approach? http://web.archive.org/web/19991116110111/http://www.rentron.com/Myke1.htm Seems to go back to articles from 1999.

      I could build this if required. This is very similar to the two wire support we have within GCB by using 'LCD_IO 2'.

       
  • Anobium

    Anobium - 2014-09-28

    @Jack. What version of the compiler? Release date please.

    I have attached a modified approach that is intended to compile without the editing of the asm file.

    I have made a few other changes to help with usability.
    1) Removed the need to edit the ASM
    2) You can added and remove the strings a little easier as the reliance on the hardcoded string length for the last string has been removed.
    3) You can now address all the strings using the printMsg routine.
    4) Tidy up of the use of EPRead.

    I cannot test. Sorry, I could not find a 74174 in my lab (I am certain I do have this device!).

     

    Last edit: Anobium 2014-09-28
  • Jack Hoffnung

    Jack Hoffnung - 2014-09-29
    HI Anobium,
    
    Version of GCBasic is the one that came with GCB@SYN,  5-11-14.
    
    The code you revised reports the same type of error as the original I sent:
    
    LCDCompileError2.gcb  (103) : Error: Syntax Error
    LCDCompileError2.gcb  (203) : Error: Syntax Error
    LCDCompileError2.gcb  (210) : Error: Syntax Error
    LCDCompileError2.gcb  (241) : Error: Syntax Error
    
    These point to these lines:
    
    EPread i, char  
    EPread index, char 
    EPread index, char
    epwrite location, Estring(ee)
    
    Again, the .asm is created, but will not assemble. Here are the errors reported:
    
    Message[302] C:\USERS\JACK\DESKTOP\LCDCOMPILEERROR2.ASM 101 : Register in operand not 
    in bank 0.  Ensure that bank bits are correct.
    Error[122]   C:\USERS\JACK\DESKTOP\LCDCOMPILEERROR2.ASM 332 : Illegal opcode (I)
    Message[302] C:\USERS\JACK\DESKTOP\LCDCOMPILEERROR2.ASM 600 : Register in operand not 
    in bank 0.  Ensure that bank bits are correct.
    Message[302] C:\USERS\JACK\DESKTOP\LCDCOMPILEERROR2.ASM 608 : Register in operand not
     in bank 0.  Ensure that bank bits are correct.
    Error[122]   C:\USERS\JACK\DESKTOP\LCDCOMPILEERROR2.ASM 865 : Illegal opcode (INDEX)
    Error[122]   C:\USERS\JACK\DESKTOP\LCDCOMPILEERROR2.ASM 894 : Illegal opcode (INDEX)
    Error[122]   C:\USERS\JACK\DESKTOP\LCDCOMPILEERROR2.ASM 1501 : Illegal opcode 
    (LOCATION)
    
    The code you sent will compile and assemble with an older version of GCBasic 
    (9-22-13), although it does not work.
    
    Hope this new information helps!
    
    Concerning the hardware, the shift register used is a 74HC595.
     Thanks for your help on this.
    
     
  • Anobium

    Anobium - 2014-09-29

    I just typed a lovely response... arghhh. Lost the posting.

    I just compiled all ok in the 6 releases I installed. So, this is odd.

    Can you please download a new copy of gcb@syn into a new folder and retest? please.

    Can you also share with me the architecture of the solution? I will recreated here.

    I can provide a one wire LCD 9600 baud control solution. It using serprint or hersprint to complete a similar task.

     
  • Jack Hoffnung

    Jack Hoffnung - 2014-09-29

    Hi Anobium,

    You nailed it; I downloaded and reinstalled and it works with no errors. Have to assume the copy I had was somehow corrupted. Sorry you spent so much time on this. Thanks for coming up with the solution!

     
  • Anobium

    Anobium - 2014-09-30

    Not a problem.

     
  • Charles Patton

    Charles Patton - 2015-06-09

    Using your post as a starting point, I developed a simple, totally GCB inline code technique so no hand editing required to add the EEmem setting code. Please see:
    https://sourceforge.net/p/gcbasic/discussion/demonstrationcode/thread/9398c719/

     

Log in to post a comment.