Need helps to how to interface PIC16F877A with graphic LCD

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Harvey » Thu Jun 23, 2011 4:58 pm

Err, that didn't work, seems I can't add attachments??
Sorry, I'm new to this stuff, can I give you my email address?
Harvey
Newbie
 
Posts: 9
Joined: Tue Jun 21, 2011 4:08 pm

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Brian Griffin » Thu Jun 23, 2011 5:56 pm

Can you post your code by placing the code between the html tags, like:

CODE: SELECT_ALL_CODE
[code]Place  your code here[/code]


Thanks. :)
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Harvey » Thu Jun 23, 2011 6:20 pm

Trying again,
CODE: SELECT_ALL_CODE
   list p=16f877         ; tells the assembler which PIC
   include "p16f877.inc"
;
   __config   _XT_OSC & _PWRTE_ON & _BODEN_OFF & _CP_ALL & _WDT_OFF & _LVP_OFF
; ***** PIC REGISTER EQUATES *****

;#define   PORTA,0   ;1   ; Analogue in LDR1
;#define   PORTA,1   ;1   ; Analogue in LDR2
;#define   PORTA,2   ;1   ; Analogue in LDR3
;#define   PORTA,3   ;1   ; Analogue in LDR4
;#define   PORTA,5   ;1   ; Analogue in ?
;#define   ftit   PORTA,4   ;0   ;

#define   xrset   PORTB,0   ;0   ; XReset for GLCD pin 17
#define   psb   PORTB,1   ;0   ; PSB GLCD pin 15, low for serial
#define   txa   PORTB,2   ;0   ; Serial out to RW pin 5
#define   ea   PORTB,3   ;0   ; SCLK pin 6
;#define   ?   PORTB,4   ;0   ;
;#define   ?   PORTB,5   ;0   ;
;#define   ?   PORTB,6   ;0   ;
;#define   red   PORTB,7   ;0   ; Red, <12.5vdc

;#define      PORTC,0   ;0   ;
;#define      PORTC,1   ;0   ;
;#define      PORTC,2   ;0   ;
;#define      PORTC,3   ;0   ;
;#define      PORTC,4   ;0   ;
;#define      PORTC,5   ;0   ;


;#define      PORTD,0      ; Pwrout port
;#define      PORTD,1      ; 0=day ok, 1=day full
;#define      PORTD,2      ; 2=night ok, 3=night full
;#define      PORTD,3      ; 4 is solar bank 1, 5 solar bank 2
;#define      PORTD,4      ; 6, 7 leds for banks
;#define      PORTD,5      ;
;#define      PORTD,6      ;
;#define      PORTD,7      ;

;#define      PORTE,0   ;0   ;
;#define      PORTE,1   ;0   ;
;#define      PORTE,2   ;0   ;
; ********** data register equates ***********

s_save   equ   70h      ; Int entry and exit, start GPR
w_save   equ   71h      ; Int entry and exit
;motstat   equ   21h
;times      equ   22h      ; cycles for serial in counter
;string   equ   23h
txdch      equ   24h      ; character to tx
rxreg      equ   25h
char_point   equ   26h      ; pointer for lookup table
sercnt   equ   27h      ; bit counter for serial out
hpcl      equ   28h      ; byte reg for PCLATH
dlycnt   equ   29h
dly1      equ   2ah      ;rs232 timers
dly2      equ   2bh      ;rs232
txd      equ   2ch      ; byte for display
lcdch      equ   2dh      ;
stat      equ   2eh      ; status flag,
;stat,0 is 0a rxed by UART, stat,1 is time updated, stat,3-7 mot pos.
atod      equ   2fh      ; A/D result
batbnk   equ   30h      ; the whole bank
bat1      equ   31h      ; temp for batbnk
addh_hld      equ   32h      ;
addl_hld      equ   33h      ;
tmph      equ   34h      ;
tmpl      equ   35h      ;
tmpcnt      equ   36h      ;
inv      equ   37h      ; inversion for sephex
stat1      equ   38h      ; second flag bank, ,0 = motor return
;1,1 is time +move ok, 1,2 is stop motor, 1,3 night on, 1,7 batt OK,
;1,5&6 is chktim
hhi      equ   39h      ; Hrs hi byte Ascii
hlo      equ   3ah      ; Hrs lo byte ascii
mhi      equ   3bh      ; Min hi byte Ascii
mlo      equ   3ch      ; Min lo byte ascii
pwrout1      equ   3dh      ; pwrout backup reg
ms_d      equ   3eh      ; Sephex
ls_d      equ   3fh      ; Sephex
fsrst      equ   40h      ; start of data for fsr
timcnt      equ   4fh      ; end of data area, page0
               ; 69 bytes 40 to 7f
               ; page 1, a0 to ef, 80 bytes
               ; page 2, 110 to 16f, 95 bytes
               ; page 3, 190 to 1ef, 95 bytes
edata      equ   65h
addrd      equ   66h
addrh      equ   67h
addrl      equ   68h
pdata      equ   69h
atod1      equ   6ah   ; There's a couple more here!
stringa                       EQU     H'0050'      ;BANK cannot ?
txdcha                        EQU     H'0051'      ; character to tx
char_pa                       EQU     H'0052'
bnkbits                       EQU     H'0053'
pwrout                       EQU     H'0054'
bata      equ   H'0055'
ftring      equ   H'0056'      ;BANK2 cannot?
ftxdch      equ   H'0057'      ; character to tx
flycnt      equ   H'0058'
ftxd      equ   H'0059'
fercnt      equ   H'005a'
fata      equ   H'005b'
cell1      equ   H'005c'
cell2      equ   H'005d'
cell3      equ   H'005e'
cell4      equ   H'005f'
cell5      equ   H'0060'
cell6      equ   H'0061'
cell7      equ   H'0062'
cell8      equ   H'0063'
temp      equ   H'0064'
lh      equ   H'0072'
; *********** reset point ***********************

   org   00      ; reset vector
   clrf    PCLATH   ; ensure page bits are cleared
   goto   init


next   movwf   PCL
sign_on   retlw   'H'
   retlw   'e'
   retlw   'l'
   retlw   'l'
   retlw   'o'
   retlw   ' '
   retlw   'M'
   retlw   'a'
   retlw   'r'
   retlw   'm'
   retlw   'y'
   retlw   ' '
   retlw   0ah
; 1026 bytes
line01   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line02   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line03   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line04   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line05   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line06   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line07   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line08   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line09   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line10   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line11   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line12   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x01
   retlw   0xFE
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line13   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0xFE
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x3F
   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line14   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x3F
   retlw   0x80
   retlw   0x01
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0xFE
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x7F
   retlw   0x80
   retlw   0x03
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x01
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line15   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xF3
   retlw   0x80
   retlw   0x07
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x3C
   retlw   0x40
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x01
   retlw   0xC3
   retlw   0xB8
   retlw   0xFF
   retlw   0xBF
   retlw   0x3E
   retlw   0x1F
   retlw   0xC0
   retlw   0x0E
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line16   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0x80
   retlw   0x39
   retlw   0xDF
   retlw   0xBE
   retlw   0xFE
   retlw   0x3F
   retlw   0xC0
   retlw   0x07
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0x80
   retlw   0x39
   retlw   0xDF
   retlw   0xBE
   retlw   0xFE
   retlw   0x3F
   retlw   0xC0
   retlw   0x03
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line17   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0x80
   retlw   0x3B
   retlw   0x9E
   retlw   0x71
   retlw   0xC2
   retlw   0x39
   retlw   0xC0
   retlw   0x01
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0x84
   retlw   0x3F
   retlw   0x9C
   retlw   0x61
   retlw   0xC6
   retlw   0x39
   retlw   0xC0
   retlw   0x01
   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line18   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0x8F
   retlw   0x3E
   retlw   0x3C
   retlw   0xE1
   retlw   0x86
   retlw   0x73
   retlw   0x80
   retlw   0x01
   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0xFE
   retlw   0x3C
   retlw   0x3E
   retlw   0xC1
   retlw   0xFE
   retlw   0x63
   retlw   0x80
   retlw   0x01
   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line19   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x01
   retlw   0xFC
   retlw   0x3C
   retlw   0x3E
   retlw   0xC1
   retlw   0xFE
   retlw   0xE3
   retlw   0x80
   retlw   0x01
   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xF8
   retlw   0x38
   retlw   0x1D
   retlw   0xC0
   retlw   0xF9
   retlw   0xE7
   retlw   0x00
   retlw   0x03
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line20   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x38
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x07
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x01
   retlw   0xF0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x18
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line21   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x01
   retlw   0xE0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x38
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line22   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x1E
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line23   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line24   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line25   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line26   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line27   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line28   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line29   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line30   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line31   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line32   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
;   retlw   0x0a
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

;*************** Delays *********

short   movlw   0x22      ;hex for 38
   movwf   dlycnt      ; delay counter
   call   dec1      ; delay routine
   return
longr   movlw   0xff
   movwf   sercnt
   goto   dah
long   movlw   0x0f      ; some of em
   movwf   sercnt      ; use any old register
dah   movlw   0xff      ; all
   movwf   dlycnt      ;
duh   decfsz   dlycnt,f
   goto   duh
   decfsz   sercnt,f
   goto   dah
   return      

delay1   movfw   dly1      
   movwf   dlycnt
dec1   decfsz   dlycnt,f
   goto   dec1
   return
delay2   movfw   dly2
   movwf   dlycnt
dec2   decfsz   dlycnt,f
   goto   dec2
   return

; ********* initalise software ******************

init   clrf   PORTA
   clrf   PORTB      ; start off with clear outputs
   clrf   PORTC
   clrf   PORTD
   clrf   PORTE

   bsf   STATUS,RP0
   bcf   STATUS,RP1
   movlw   b'00000000'   ; porta all outputs
   movwf   TRISA      ;
   movlw   b'00000000'
   movwf   TRISE
   movlw   b'00000000'   ;
   movwf   TRISD      ;
   movlw   b'11000000'   ; Trisc 7,6 must be set for UART
   movwf   TRISC      ;
   movlw   b'00000000'   ; All outputs b0 is xrset
   movwf   TRISB      ; b1-psb, b2-txa, b3-ea
   bcf   STATUS,RP0   ; Bank 0
   nop
   bcf   xrset
   call   longr      ; more than 40ms!
   call   init_1      ; init GLCD
   call   dline1      ;
   movlw   sign_on      ; Hello Marmy
   call   disp_3      ; send
   call   long
   call   dline4a      ;
   movlw   sign_on      ; Hello Marmy
   call   disp_3      ; send
   call   longr
   call   longr
   call   longr
   call   longr
   call   longr
   call   longr
   call   longr
   call   longr
   movlw   0x34   ; Function set extended
   movwf   lcdch   ; with graphics off
   call   cmdlcd
   call   short   ; >100us
   movlw   0x02   ; enable Graph Ram
   movwf   lcdch
   call   cmdlcd
   call   short   ; >100us
   movlw   b'10000000'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line01
   call   disp_3
   movlw   b'10000001'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   clrf   PCLATH
   movlw   line02
   call   disp_3
   movlw   b'10000010'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line03
   call   disp_3
   movlw   b'10000011'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line04
   call   disp_3
   movlw   b'10000100'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line05
   call   disp_3
   movlw   b'10000101'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line06
   call   disp_3
   movlw   b'10000110'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line07
   call   disp_3
   movlw   b'10000111'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   bsf   PCLATH,0
   movlw   line08
   call   disp_3
   movlw   b'10001000'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line09
   call   disp_3
   movlw   b'10001001'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line10
   call   disp_3
   movlw   b'10001010'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line11
   call   disp_3
   movlw   b'10001011'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line12
   call   disp_3
   movlw   b'10001100'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line13
   call   disp_3
   movlw   b'10001101'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line14
   call   disp_3
   movlw   b'10001110'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line15
   call   disp_3
   movlw   b'10001111'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line16
   call   disp_3
   movlw   b'10010000'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line17
   call   disp_3
   movlw   b'10010001'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line18
   call   disp_3
   movlw   b'10010010'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line19
   call   disp_3
   movlw   b'10010011'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line20
   call   disp_3
   movlw   b'10010100'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line21
   call   disp_3
   movlw   b'10010101'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line22
   call   disp_3
   movlw   .150      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line23
   call   disp_3
   movlw   .151      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line24
   call   disp_3
   movlw   .152      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line25
   call   disp_3
   movlw   .153      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line26
   call   disp_3
   movlw   .154      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line27
   call   disp_3
   movlw   .155      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line28
   call   disp_3
   movlw   .156      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line29
   call   disp_3
   movlw   .157      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line30
   call   disp_3
   movlw   .158      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line31
   call   disp_3
   movlw   .159      ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd
   movlw   line32
   call   disp_3
;   movlw   .160      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line31
;   bsf   PCLATH,1
;   bcf   PCLATH,0
;   call   disp_3
;   movlw   .161      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line32
;   call   disp_3
;   movlw   .162      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line33
;   call   disp_3
;   movlw   .163      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line34
;   call   disp_3
;   movlw   .164      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line35
;   call   disp_3
;   movlw   .165      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line36
;   call   disp_3
;   movlw   .166      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line37
;   call   disp_3
;   movlw   .167      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line38
;   call   disp_3
;   movlw   .168      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;;   movlw   line39
;   call   disp_3
;   movlw   .169      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line40
;   call   disp_3
;   movlw   .170      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line41
;   call   disp_3
;   movlw   .171      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line42
;   call   disp_3
;   movlw   .172      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line43
;   call   disp_3
;   movlw   .173      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line44
;   call   disp_3
;   movlw   .174      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line45
;   call   disp_3
;   movlw   .175      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line46
;   bsf   PCLATH,0
;   call   disp_3
;   movlw   .176      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line47
;   call   disp_3
;   movlw   .177      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line48
;   call   disp_3
;   movlw   .178      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line49
;   call   disp_3
;   movlw   .179      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line50
;   call   disp_3
;   movlw   .180      ; set gram add vert
;;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line51
;   call   disp_3
;   movlw   .181      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line52
;   call   disp_3
;   movlw   .182      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line53
;   call   disp_3
;   movlw   .183      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line54
;   call   disp_3
;   movlw   .184      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line55
;   call   disp_3
;   movlw   .185      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line56
;   call   disp_3
;   movlw   .186      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line57
;   call   disp_3
;   movlw   .187      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line58
;   call   disp_3
;   movlw   .188      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line59
;   call   disp_3
;   movlw   .189      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line60
;   call   disp_3
;   movlw   .190      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line61
;   bsf   PCLATH,2
;   bcf   PCLATH,1
;   bcf   PCLATH,0
;   call   disp_3
;   movlw   .191      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line62
;   call   disp_3
;   movlw   .192      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;   movwf   lcdch
;   call   cmdlcd
;   movlw   line63
;   call   disp_3
;   movlw   .193      ; set gram add vert
;   movwf   lcdch
;   call   cmdlcd
;   movlw   b'10000000'   ; set gram add horiz
;;   movwf   lcdch
;   call   cmdlcd
;   movlw   line64
;   call   disp_3
;   bsf   PCLATH,1
   movlw   b'10000000'   ; set gram add vert
   movwf   lcdch
   call   cmdlcd
   movlw   b'10000000'   ; set gram add horiz
   movwf   lcdch
   call   cmdlcd

   movlw   0x36   ; Graphic Display on
   movwf   lcdch
   call   cmdlcd
   call   short   ; >100us
   Call   longr
   call   longr
   Call   longr
   call   longr
   Call   longr
   call   longr
   Call   longr
   call   longr
   movlw   0x34   ; Function set extended
   movwf   lcdch   ; with graphics off
   call   cmdlcd
   call   short   ; >100us

   movlw   0x32   ; Back to Function set basic
   movwf   lcdch   ; with graphics on and SR=0
   call   cmdlcd
   call   short   ; >100us
   goto   init
   sleep



init_1   ;call   long   ; >40ms from startup
   bsf   xrset   ; XRESET to high
   movlw   0x30   ; Function set GLCD
   movwf   lcdch   ; for sending
   call   cmdlcd   ; send it
   call   short   ; >100us
   call   cmdlcd   ; send it again
   call   short   ; > 37us
   movlw   0x0c   ; Display on
   movwf   lcdch
   call   cmdlcd
   call   short   ; >100us
   movlw   0x01   ; Display Clear
   movwf   lcdch
   call   cmdlcd   ; send
   call   long   ; >10ms
;   movlw   0x06   ; Entry mode set
;   movwf   lcdch   ; Brian didn't use this?
;   call   cmdlcd   ; end init
   return

dline1   movlw   0x80   ;
   movwf   lcdch
   call   cmdlcd
   return
dline2   movlw   0x90   ;
   movwf   lcdch
   call   cmdlcd
   return
dline3   movlw   0xa0   ;
   movwf   lcdch
   call   cmdlcd
   return
dline4   movlw   0xb0   ;
   movwf   lcdch
   call   cmdlcd
   return
dline3a   movlw   0x88   ;
   movwf   lcdch
   call   cmdlcd
   return
dline4a   movlw   0x98   ;
   movwf   lcdch
   call   cmdlcd
   return



disp_3   movwf   char_point   ; get loc into character pointer
disp_4   movfw   char_point   ; and back to w
   call   next      ; put it in the PC
   movwf   txdch      ; the character is in w so load it to file
   xorlw   0ah      ; eom or not?
   btfsc   STATUS,Z   ; test it
   retlw   0x00      ; all done go away
   movfw   txdch      ; ! get it for disp
   movwf   lcdch      
   call   senlcd
   incf   char_point,f   ; ready for next character
   goto   disp_4      ; go to it!

cmdlcd   movlw   b'11111000'   ;rs to 0
   movwf   txd
   call   serdis
   movlw   b'11110000'   ; send first half and 4 0s
   andwf   lcdch,w      ;;data to send
   movwf   txd
   call   serdis
   swapf   lcdch,f
   movlw   b'11110000'   ; send second half and 40s
   andwf   lcdch,w      ;data to send
   movwf   txd
   swapf   lcdch,f
   call   serdis
   retlw   0x00

senlcd   movlw   b'11111010'   ;rs to 1
   movwf   txd
   call   serdis
   movlw   b'11110000'   ; send first half and 4 0s
   andwf   lcdch,w
   movwf   txd
   call   serdis
   swapf   lcdch,f
   movlw   b'11110000'   ; send second half and 40s
   andwf   lcdch,w
   movwf   txd
   swapf   lcdch,f
   call   serdis
   retlw   0x00

serdis   movlw   0x08      ; 8 bit counter
   movwf   sercnt
bitout   bcf   txa      ; serial out to 164
   btfsc   txd,7      ; the old circle test for serial
   bsf   txa
   bsf   ea      ; clock it in to 164
   nop
   nop
   bcf   ea
   rlf   txd,f      ; shift data left
   decfsz   sercnt,f   ; count down no of bits
   goto   bitout
   bcf   txa
   return

gerdis   movlw   0x05
   movwf   temp
   bsf   txa      ;*five consecutive ones
gtout   bsf   ea      ; start
   nop
   nop         ;
   bcf   ea
   nop
   decfsz   temp,f
   goto   gtout
   nop         ; ones sent
   bcf   txa      ; serial out to glcd
   btfsc   stat,0      ;*the RW 
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; RW sent
   bcf   txa      ; serial out to glcd
   btfsc   stat,1      ;*the RS
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; RS sent
   bcf   txa
   nop
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; one zero sent
   bcf   txa
   btfsc   txd,7      ;
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; bit 7 sent
   bcf   txa      ; serial out to glcd
   btfsc   txd,6      ;
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; bit 6 sent
   bcf   txa
   btfsc   txd,5      ;
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; bit 5 sent
   bcf   txa
   bcf   txa
   btfsc   txd,4      ;
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; bit 4 sent
   bcf   txa
   call   four0
   btfsc   txd,3      ;
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; bit 3 sent
   bcf   txa      ; serial out to glcd
   btfsc   txd,2      ;
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; bit 2 sent
   bcf   txa
   btfsc   txd,1      ;
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; bit 1 sent
   bcf   txa
   bcf   txa
   btfsc   txd,0      ;
   bsf   txa
   bsf   ea      ; clock
   nop
   nop
   bcf   ea      ; bit 0 sent
   bcf   txa
   call   four0
   return
four0   movlw   0x04
   movwf   temp
   bcf   txa      ;*four consecutive zeros
say4   bsf   ea      ; start
   nop
   nop         ;
   bcf   ea
   nop
   decfsz   temp,f
   goto   say4
   return

   end
line01   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line02   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line03   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line04   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line05   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line06   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line07   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line08   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x01
   retlw   0x0a

line09   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0x1C
   retlw   0x60
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x7F
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line10   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line11   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x01
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line12   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0xF0
   retlw   0x0C
   retlw   0xFE
   retlw   0x02
   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x1F
   retlw   0x20
   retlw   0x3F
   retlw   0x20
   retlw   0x0a

line13   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line14   retlw   0x00
   retlw   0x00
   retlw   0xE0
   retlw   0x1F
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xC0
   retlw   0x38
   retlw   0x07
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line15   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xC0
   retlw   0x30
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line16   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x02
   retlw   0x0C
   retlw   0x08
   retlw   0x10
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x0a

line17   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x3F
   retlw   0x00
   retlw   0x20
   retlw   0x20
   retlw   0x50
   retlw   0x50
   retlw   0x50
   retlw   0x88
   retlw   0xFF
   retlw   0x0a

line18   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xE0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line19   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x08
   retlw   0x78
   retlw   0x50
   retlw   0x08
   retlw   0x04
   retlw   0x06
   retlw   0x03
   retlw   0x0a

line20   retlw   0x7E
   retlw   0x02
   retlw   0x00
   retlw   0x00
   retlw   0x01
   retlw   0x01
   retlw   0x00
   retlw   0x80
   retlw   0x3E
   retlw   0x20
   retlw   0x00
   retlw   0x00
   retlw   0x80
   retlw   0x80
   retlw   0x00
   retlw   0x01
   retlw   0x0a

line21   retlw   0x00
   retlw   0x00
   retlw   0x40
   retlw   0x20
   retlw   0x60
   retlw   0x90
   retlw   0x80
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line22   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line23   retlw   0x08
   retlw   0x06
   retlw   0x02
   retlw   0x01
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x0a

line24   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x0a

line25   retlw   0x19
   retlw   0x07
   retlw   0x01
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x07
   retlw   0x04
   retlw   0x08
   retlw   0x07
   retlw   0x04
   retlw   0xDA
   retlw   0x22
   retlw   0xDA
   retlw   0x07
   retlw   0x01
   retlw   0x0a

line26   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x0a

line27   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x1E
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x2E
   retlw   0x0a

line28   retlw   0xE0
   retlw   0x3C
   retlw   0x03
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x08
   retlw   0x07
   retlw   0x38
   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xE2
   retlw   0x0a

line29   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x08
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line30   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line31   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x0a

line32   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x0a

line33   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line34   retlw   0x02
   retlw   0x03
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0xFE
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x02
   retlw   0x0a

line35   retlw   0x21
   retlw   0x41
   retlw   0x07
   retlw   0x39
   retlw   0x41
   retlw   0x41
   retlw   0x43
   retlw   0x3D
   retlw   0x32
   retlw   0x21
   retlw   0x21
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x0a

line36   retlw   0x09
   retlw   0x12
   retlw   0x12
   retlw   0xA3
   retlw   0xA2
   retlw   0xA2
   retlw   0x41
   retlw   0x40
   retlw   0x12
   retlw   0x0A
   retlw   0x09
   retlw   0xF9
   retlw   0x00
   retlw   0x08
   retlw   0x10
   retlw   0xE0
   retlw   0x0a

line37   retlw   0x08
   retlw   0x10
   retlw   0x10
   retlw   0x10
   retlw   0xA0
   retlw   0xA0
   retlw   0xA0
   retlw   0x40
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line38   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x02
   retlw   0x02
   retlw   0x05
   retlw   0x05
   retlw   0x05
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line39   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x0a

line40   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x20
   retlw   0x0a

line41   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line42   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line43   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line44   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x01
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line45   retlw   0x40
   retlw   0x40
   retlw   0x80
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x03
   retlw   0x01
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line46   retlw   0x08
   retlw   0xFF
   retlw   0x90
   retlw   0x70
   retlw   0x10
   retlw   0x2D
   retlw   0x22
   retlw   0x2D
   retlw   0x80
   retlw   0xFE
   retlw   0x8C
   retlw   0x70
   retlw   0x40
   retlw   0xA0
   retlw   0x20
   retlw   0xA0
   retlw   0x0a

line47   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x80
   retlw   0x0a

line48   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x10
   retlw   0x08
   retlw   0x0C
   retlw   0x02
   retlw   0x01
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line49   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x80
   retlw   0x60
   retlw   0x1C
   retlw   0x03
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x80
   retlw   0x0a

line50   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line51   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line52   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line53   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line54   retlw   0x70
   retlw   0x40
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x70
   retlw   0x10
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x07
   retlw   0x38
   retlw   0x0a

line55   retlw   0x01
   retlw   0x02
   retlw   0x06
   retlw   0x08
   retlw   0x30
   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line56   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line57   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x7F
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line58   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line59   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line60   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line61   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xFF
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line62   retlw   0x1F
   retlw   0xE0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0xC0
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a

line63   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
line64   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x00
   retlw   0x0a
Harvey
Newbie
 
Posts: 9
Joined: Tue Jun 21, 2011 4:08 pm

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Brian Griffin » Thu Jun 23, 2011 6:29 pm

Unfortunately my PIC16F assembler is rusty.

Have you tried writing a barebones program that just display the words like what I posted previously?

Thanks
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Harvey » Thu Jun 23, 2011 9:22 pm

That actually does display "Hello Marmy" on the specified lines, the second part, trying to display the Cytron Logo doesn't work, just fills the screen with very small illegible characters. PR21 has C code to display it, but the detailed explanation file is corrupt, can dload cannot read. Oh well, I'll just keep trying, I'll let you know if I have a win, thanks.
:)
Harvey
Newbie
 
Posts: 9
Joined: Tue Jun 21, 2011 4:08 pm

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Brian Griffin » Thu Jun 23, 2011 11:55 pm

Have you set the "Graphics Mode" in the LCD yet? According to it if you need to draw stuff on it you need to send the specified value to the LCD. You will have to flip between the "Graphics Mode" and "Text Mode" if you have to do both together.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Harvey » Mon Jun 27, 2011 9:04 pm

Yes, I can switch between text and graphics but not back to text, have to reset it for that. The PR21 'C' code says "display second half" but I can't understand how it's halved. There is no explanation in the datasheet of what Scroll Address is at all, can anyone help me with that?
Harvey
Newbie
 
Posts: 9
Joined: Tue Jun 21, 2011 4:08 pm

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Brian Griffin » Tue Jun 28, 2011 8:02 pm

The drawing of the graphics in ST7920 can be very confusing, and I fell into that kind of trap as well.

The display is divided into four strips, something like this ( I put an example sentence inside ) :

CODE: SELECT_ALL_CODE
+----------------------+
| Hello World          |  (address 0x80)
+----------------------+
| Ni Hao Ma?           |  (address 0x90)
+----------------------+
| etc..                |  (address 0x88)
+----------------------+
|                      |  (address 0x98)
+----------------------+


When drawing, it becomes two major strips instead :

CODE: SELECT_ALL_CODE
+----------------------+
|                      |  (address 0x80)
+                      +
|                      |  (address 0x90)
+----------------------+
|                      |  (address 0x88)
+                      +
|                      |  (address 0x98)
+----------------------+


That explains the two halves mentioned in the Cytron demo program.

Here is a working prototype of that function which fills up the screen with the graphic. It is a modified dfRobot example but it works on my system.

CODE: SELECT_ALL_CODE
void ST7920_FillScreenPic(const char* graphic)
{
  int ygroup,x,y,i;
      int temp;
      int tmp;

      for(ygroup=0;ygroup<64;ygroup++)
        {
           if(ygroup<32)
            {
             x=0x80;
             y=ygroup+0x80;
            }
           else
            {
              x=0x88;
              y=ygroup-32+0x80;
            }
           ST7920_Command(0x34);
           ST7920_Command(y);
           ST7920_Command(x);
           ST7920_Command(0x30);
           tmp=ygroup*16;
           for(i=0;i<16;i++)
            {
                    temp=graphic[tmp++];
                    ST7920_Data(temp);
            }
          }
        ST7920_Command(0x34);
        ST7920_Command(0x36);
}


Again, I used the graphic array:
Spoiler: show
const char graphic[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 255, 255, 255, 255, 255, 255, 128,
0, 0, 0, 0, 0, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 224,
0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 96,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, 255, 255, 255, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, 255, 255, 255, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 248, 15, 255, 128, 63, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 3, 252, 0, 7, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 1, 240, 0, 1, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 231, 249, 224, 0, 0, 127, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 239, 249, 128, 0, 0, 63, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 3, 128, 0, 0, 63, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 3, 0, 0, 0, 31, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 240, 7, 0, 14, 0, 15, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 254, 0, 15, 0, 15, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 254, 0, 31, 0, 15, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 227, 254, 0, 31, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 225, 254, 0, 31, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 14, 0, 31, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 14, 0, 31, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 14, 0, 31, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 254, 0, 15, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 239, 238, 0, 0, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 225, 142, 0, 0, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 225, 14, 0, 0, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 248, 30, 0, 0, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 232, 14, 0, 0, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 14, 0, 0, 0, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 14, 0, 15, 255, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 239, 254, 0, 31, 255, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 254, 0, 31, 255, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 236, 14, 0, 31, 128, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 236, 14, 0, 31, 128, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 232, 14, 0, 31, 128, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 254, 0, 31, 128, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 254, 0, 31, 128, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 14, 0, 31, 128, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 14, 0, 31, 128, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 6, 0, 31, 128, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 239, 254, 0, 31, 128, 7, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 254, 0, 15, 0, 15, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 7, 0, 15, 0, 15, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 3, 0, 4, 0, 15, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 3, 128, 0, 0, 31, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 239, 255, 128, 0, 0, 63, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 239, 255, 192, 0, 0, 127, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 0, 224, 0, 0, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 0, 120, 0, 1, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 224, 0, 62, 0, 7, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, 255, 255, 255, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, 255, 255, 255, 255, 176,
0, 0, 0, 0, 0, 0, 0, 0, 6, 255, 255, 255, 255, 255, 255, 112,
0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 96,
0, 0, 0, 0, 0, 0, 0, 0, 3, 255, 255, 255, 255, 255, 255, 192,
0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 128,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Harvey » Tue Jun 28, 2011 9:28 pm

Really great, thanks so much. The perplexing thing is that the datasheets from the manufacturer and Tinsharp are so misleading, even the text addressing is wrong. Anyway it'l take me a while to figure out what you are doing and get it to display but you've put me on the right track, I hope your info helps others as well, I'm sure I wasn't the only one in this predicament, Cheers. Thanks.
Harvey
Newbie
 
Posts: 9
Joined: Tue Jun 21, 2011 4:08 pm

Re: Need helps to how to interface PIC16F877A with graphic L

Postby Brian Griffin » Tue Jun 28, 2011 9:57 pm

Harvey WROTE:Really great, thanks so much. The perplexing thing is that the datasheets from the manufacturer and Tinsharp are so misleading, even the text addressing is wrong. Anyway it'l take me a while to figure out what you are doing and get it to display but you've put me on the right track, I hope your info helps others as well, I'm sure I wasn't the only one in this predicament, Cheers. Thanks.


You should see a truck or a home picture there if it works.

The tougher thing about PIC16F is, there is no multiply instruction, so try to shift the register to the right four times:

CODE: SELECT_ALL_CODE
tmp=ygroup*16;


or

CODE: SELECT_ALL_CODE
tmp=ygroup << 4;


Shifting in ASM is easier, but I don't remember much of ASM 16F. Check the instruction list for the exact name.
PIC - UIC00B from Cytron (replacement for my broken PICKit 2), Pickit 3, MikroC for PIC
dsPIC - MikroC for dsPIC, mikromedia board (dsPIC33)
AVR - AVR Dragon
Parallax - Prop tool
User avatar
Brian Griffin
Enthusiast
 
Posts: 403
Joined: Mon Jan 17, 2011 9:36 am

PreviousNext

Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 0 guests