Hi
This code can replace the code inserted by PBP whenever you use the LCDOUT command.
The reasons to do so are for probably speed and memory savings.
Also, since LCDOUT is meaningless in any other language, it will be needed unless you never use anything else.

Name:  Screen Shot 2019-04-10 at 9.44.07 pm.png
Views: 55
Size:  558.6 KB

This is tested as is with 16F628A at 10 MHz, and the output in the image is the small demo routine.
Use it as you will (or not).
Cheers, Brek.

Code:
'
'****************************************************************
'*                                                              *
'*               PBP LCDOUT Replacement Functions               *
'*                    Brek Martin (Art) 2019                    *
'*                                                              *
'****************************************************************
'
' RA0 = lcd d0
' RA1 = lcd d1
' RA2 = lcd d2
' RA3 = lcd d3
' RA4 = lcd rs
' RB2 = lcd en
'
DEFINE OSC 10
'
E_PIN var portb.2
'
CMCON = 7			'set ports to digital
trisb = %01000000  	'
trisa = %00000000	'
'
rsflag var bit
lata var byte		'port a latch
arg var byte		'function arguments
nib var byte		'
cnt var byte		'counter
worka var word		'work variables
workb var word		'
line var byte[16] 	'string array
'
'******************************************************************************
'
pause 1000			'one second delay before talking to the LCD
gosub lcdinit		'initialise lcd
'
line[0] = "H"		'set data
line[1] = "e"		'
line[2] = "l"		'
line[3] = "l"		'
line[4] = "o"		'
'
arg = $02 : gosub send_command_byte 'go to start of line 1
for cnt = 0 to 4	'print line 1
arg = line[cnt] : gosub send_data_byte
next cnt
'
worka = 12345		'set data (this data is destroyed)
workb = 10000		'
'
arg = $C0 : gosub send_command_byte 'go to start of line 2
for cnt = 0 to 4
arg = worka / workb
worka = worka - (arg*workb)
arg = arg + $30 : gosub send_data_byte
workb = workb / 10
next cnt
'
infinite:			'do forever
pause 10
goto infinite
'
'******************************************************************************
'
' HD44780 lcd functions
'
lcdinit:	'module initialisation sequence for 4 bit interface
nib = $03 : gosub send_nibble
pause 6		' must be more than 4.1ms
nib = $03 : gosub send_nibble
pause 6		' must be more than 100us
nib = $03 : gosub send_nibble
pause 6		' must be more than 4.1ms
nib = $02 : gosub send_nibble	'set 4 bit mode
pause 6		'2x16 character LCD display settings
arg = %00101000 : gosub send_command_byte 'N=0 : 2 lines F=0 : 5x7 font
pause 10
arg = %00001000 : gosub send_command_byte 'display: display off, cursor off, blink off
pause 10
arg = %00000001 : gosub send_command_byte 'clear display
pause 10
arg = %00000110 : gosub send_command_byte 'set entry mode
pause 10
arg = %00001100 : gosub send_command_byte 'display: display on
pause 10
return
'
'
send_nibble:
E_PIN = 1
lata = nib & $0F
lata.4 = rsflag
porta = lata
pause 1 'both of these pauses should be
@ nop	'replaed with a bunch of nops
@ nop	'after testing like this, or it
@ nop	'will be much slower than lcdout
@ nop	'start with ten or so either side
E_PIN = 0
pause 1 'enough time for slowest command
@ nop	'replace this pause with nops too
return
'
'
send_command_byte:
rsflag = 0
goto send_byte
send_data_byte:
rsflag = 1
send_byte:
nib = arg >> 4 : gosub send_nibble
nib = arg & $F : gosub send_nibble
return
'
'
'******************************************************************************