Learning to Drive an LCD DISPLAY

#41
Mark I got it to display correctly on a 08m2 with this code

Code:
[color=Blue]serout c.0[/color][color=Black],[/color][color=Blue]n9600_8[/color][color=Black],[/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]1[/color][color=Blue])
pause [/color][color=Navy]2[/color]
[color=Blue]serout c.0[/color][color=Black],[/color][color=Blue]n9600_8[/color][color=Black],[/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]128[/color][color=Blue]) [/color][color=Green]; move to start of first line[/color]
[color=Blue]pause [/color][color=Navy]2     [/color]
[color=Blue]serout c.0[/color][color=Black],[/color][color=Blue]n9600_8[/color][color=Black],[/color][color=Blue]([/color][color=Red]"88888888888888888888"[/color][color=Blue]) [/color][color=Green]; output text[/color]
[color=Blue]pause [/color][color=Navy]2     [/color]
[color=Blue]serout c.0[/color][color=Black],[/color][color=Blue]n9600_8[/color][color=Black],[/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]192[/color][color=Blue]) [/color][color=Green]; move to start of first line[/color]
[color=Blue]pause [/color][color=Navy]20    [/color]
[color=Blue]serout c.0[/color][color=Black],[/color][color=Blue]n9600_8[/color][color=Black],[/color][color=Blue]([/color][color=Red]"88888888888888888885"[/color][color=Blue]) [/color][color=Green]; output text[/color]
[color=Blue]pause [/color][color=Navy]2     [/color]
[color=Blue]serout c.0[/color][color=Black],[/color][color=Blue]n9600_8[/color][color=Black],[/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]148[/color][color=Blue]) [/color][color=Green]; move to start of first line[/color]
[color=Blue]pause [/color][color=Navy]20    [/color]
[color=Blue]serout c.0[/color][color=Black],[/color][color=Blue]n9600_8[/color][color=Black],[/color][color=Blue]([/color][color=Red]"88888888888888888885"[/color][color=Blue]) [/color][color=Green]; output text[/color]
[color=Blue]pause [/color][color=Navy]2     [/color]
[color=Blue]serout c.0[/color][color=Black],[/color][color=Blue]n9600_8[/color][color=Black],[/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]212[/color][color=Blue]) [/color][color=Green]; move to start of first line[/color]
[color=Blue]pause [/color][color=Navy]20    [/color]
[color=Blue]serout c.0[/color][color=Black],[/color][color=Blue]n9600_8[/color][color=Black],[/color][color=Blue]([/color][color=Red]"88888888888888888888"[/color][color=Blue]) [/color][color=Green]; output text[/color]
those are about the minimum amount of pauses required
http://youtu.be/M-27C_nIqII


in your control section can i add my own case say "$57" and have it do another set of codes
Code:
[color=Black]Commands:
   [/color][color=Blue]SERIN [/color][color=Black]Rx,[/color][color=Blue]N9600_32[/color][color=Black],sentdata
   [/color][color=Purple]pinsC [/color][color=DarkCyan]= [/color][color=Black]sentdata [/color][color=DarkCyan]/ [/color][color=Navy]16 
   [/color][color=Blue]IF [/color][color=Purple]pinsc [/color][color=DarkCyan]= [/color][color=Navy]$2 [/color][color=Blue]then [/color][color=Black]Control 
   [/color][color=Blue]LOW [/color][color=Black]RS
    [/color][color=Blue]PULSOUT [/color][color=Black]E,[/color][color=Navy]1 [/color][color=Black]: [/color][color=Purple]pinsC [/color][color=DarkCyan]= [/color][color=Black]sentdata : [/color][color=Blue]PULSOUT [/color][color=Black]E,[/color][color=Navy]1
   [/color][color=Blue]HIGH [/color][color=Black]RS 
    [/color][color=Blue]GOTO [/color][color=Black]Main
    
Control: 
   [/color][color=Blue]SELECT CASE [/color][color=Black]sentdata
   [/color][color=Blue]case  [/color][color=Navy]$20  [/color][color=Blue]low b.0
   case  [/color][color=Navy]$21 [/color][color=Blue]high b.0
   case  [/color][color=Navy]$22  [/color][color=Blue]low b.5
   case  [/color][color=Navy]$23 [/color][color=Blue]high b.5
   case  [/color][color=Navy]$24  [/color][color=Blue]low b.2
   case  [/color][color=Navy]$25 [/color][color=Blue]high b.2
   case  [/color][color=Navy]$26  [/color][color=Blue]low b.3
   case  [/color][color=Navy]$27 [/color][color=Blue]high b.3
   END SELECT
    GOTO [/color][color=Black]Main  [/color]
i want to be able to add a RTC to this 20m2 thats running the lcd and send a code from a 08m2 to retrieve that info
 

marks

Senior Member
#42
Hi ac21,
glad to see your've had a win.
you should be able to use $20-$70(command lcd codes we wont be needing).

It would be easier to code if the RTC were added to the 08m2
time to draw out a plan i always look at the hardware first, requiring the least ammount of easy coding lol.

Ruff examples here we could probaly improve upon.whatever control tasks we employ remember may require addition pause times to complete.
Code:
#picaxe 18m2  ' version 2.A * Testdrive 4bit/8bit Serial driver boards* marks
SETFREQ M16
                                ' when using 4bit board to send I use c.0 
main:
serout b.0,n9600_16,(254,192)   ' Command Line 2 Cursor Position
pause 2
serout b.0,n9600_16,("Marks 9600          ")
pause 45
  serout b.0,n9600_16,(254,$21) ' Control High OUTPUT 1
pause 4000
              
serout b.0,n9600_16,(254,192)   ' Command Line 2 Cursor Position
pause 2
serout b.0,n9600_16,("           123456789") 
pause 45
  serout b.0,n9600_16,(254,$50) ' Control Low OUTPUT 1  
pause 2000
goto main
Code:
	#picaxe 18m2    'version 2.A * 4 BIT SERIAL DRIVER 9600 baud * marks							
	#terminal off	
'            DB7  = C.3	
'            DB6  = C.2	
'            DB5  = C.1	
'            DB4  = C.0	           
      SYMBOL Rx   = C.5
	SYMBOL E    = B.6			                  
	SYMBOL RS   = B.7			                  
	SYMBOL senddata    = b0	 SYMBOL sentdata    = b0			
	SYMBOL index       = b1
	SYMBOL batV        = b2 
	SYMBOL ADCval      = b3
      SYMBOL D1          = b4 
	SYMBOL D2          = b5 
	
	EEPROM 0 ,($03,$03,$03,$02,$02,$08,$0,$0C,$0,$01)'(4Bit)(2line/5x8)(Display On)(Clear Display)	 16  8  4  2  1                                                
      EEPROM 10,(6 ,9 ,9 ,6 ,0 ,0 ,0 ,0) ' load custom character (o) =0                                 *  '  '  '  *  17
      EEPROM 18,(14,17,17,31,17,17,0 ,0) ' load custom character (A) =1                                 *  *  '  *  *  27
      EEPROM 26,(30,17,17,30,16,16,0 ,0) ' load custom character (P) =2                                 *  '  *  '  *  21
      EEPROM 34,(17,27,21,17,17,17,0 ,0) ' load custom character (M) =3                                 *  '  '  '  *  17
      EEPROM 42,(14,17,16,16,17,14,0 ,0) ' load custom character (C) =4                                 *  '  '  '  *  17
      EEPROM 50,(30,16,16,28,16,16,0 ,0) ' load custom character (F) =5                                 *  '  '  '  *  17
      EEPROM 58,(0 ,31,1 ,31,16,16,31,0) ' load custom character (2) =6                                 '  '  '  '  '  0
      EEPROM 66,(14,10,14,0 ,14,10,10,0) ' load custom character (on)=7                                 '  '  '  '  '  0
                                         '                                                           custom character example (M)=3
	CALIBADC10 ADCval
      SETFREQ M32
 	dirsB = %11101101			
 	dirsC = %00001111								
 	batV = 10475 / ADCval
      BinToAscii batV,D2,D2,D1 
      
Initialise: 	
	FOR  index = 0 to 9                                               
          READ index, senddata : pinsC = senddata : PULSOUT E,1 ' Initialise LCD						
 	NEXT index : PAUSE 10
 	
DisplaySupply:
	HIGH RS
      FOR  index = 0 TO 15
 	    LOOKUP index,("LCD Supply ",D2,".",D1,"V "),sentdata 
 	                           pinsC = senddata / 16 : PULSOUT E,1 : pinsC = senddata : PULSOUT E,1 ' sending characters to line one 
      NEXT index

LoadCustomCharactersFromEEPROM:
       LOW RS : senddata = $40 : pinsC = senddata / 16 : PULSOUT E,1 : pinsC = senddata : PULSOUT E,1 : HIGH RS ' Load Characters to LCD	
 	FOR  index =10 TO 73                 
 	    READ index, senddata : pinsC = senddata / 16 : PULSOUT E,1 : pinsC = senddata : PULSOUT E,1 ' sending characters to LCD      
 	NEXT index    
 
' TestCustomCharacters:
'       LOW RS  :senddata = 192 : pinsC = senddata / 16 : PULSOUT E,1 : pinsC = senddata : PULSOUT E,1  '(192-211) Line 2 Cursor Position
'      HIGH RS
'      FOR  index = 0 TO 12
' 	    LOOKUP index,("Test ",0,1,2,3,4,5,6,7),senddata 
' 	                            pinsC = senddata / 16 : PULSOUT E,1 : pinsC = senddata : PULSOUT E,1 ' sending characters to line two 
'      NEXT index
 
Main:
    bptr=28
   SERIN Rx,N9600_32,@bptr
   IF @bptrinc = 254 THEN Commands
   SERIN [10],Rx,N9600_32,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,_
                          @bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc ' upto 20 Characters
    @bptr = 254
     bptr = 28
       do until @bptr = 254
        pinsC = @bptr / 16 : PULSOUT E,1 : pinsC = @bptrinc : PULSOUT E,1
       loop
   GOTO Main
   
Commands:
   SERIN Rx,N9600_32,sentdata
   pinsC = sentdata / 16 
   IF pinsc = $2 then Control2x 
   IF pinsc = $5 then Control5x
   LOW RS
    PULSOUT E,1 : pinsC = sentdata : PULSOUT E,1
   HIGH RS 
    GOTO Main
    
Control2x: 
   SELECT CASE sentdata
   case  $22  low b.5
   case  $23 high b.5
   case  $24  low b.2
   case  $25 high b.2
   case  $26  low b.3
   case  $27 high b.3
   case  $21 high b.0
   END SELECT
    GOTO Main 
    
    Control5x: 
   SELECT CASE sentdata  
   case  $52  low b.5
   case  $53 high b.5
   case  $54  low b.2
   case  $55 high b.2
   case  $56  low b.3
   case  $57 high b.3
   case  $50  low b.0
   END SELECT
    GOTO Main
 

marks

Senior Member
#43
9600 Bps or Hi2Cfast OLed/LCD firmware for the 20x2picaxe

Lately there's been some interest using 9600 Bps or Hi2C to drive a Display.
originally an 18m2 was used for sending our data to 20x2picaxe driver in post#20
but many are wanting to use the bigger chips so I'm adding some examples using the 40x2
which should also work with the 28x2 as slight code variations can sometimes be needed with different chips.
I've separated them so hopefully this will make it easier to get started!
N9600
Code:
#picaxe 20X2   '  versions C.0 C.1 C.3    *LCD/OLED driver 4Bit (9600Bps)* marks						
#no_data       '    .-----_-----.
#terminal off  '    | V+     0V |
               ' -->| SI     SO |--> a.0 Control output
'       Rx N9600 -->| C.7   B.0 |--> LCD DB4
'  (10K pulldown)   | C.6   B.1 |--> LCD DB5
'                   | C.5   B.2 |--> LCD DB6
'                   | C.4   B.3 |--> LCD DB7
'         LCD E  <--| C.3   B.4 |
'         LCD RS <--| C.2   B.5 |
'                   | C.1   B.6 |
'                   | C.0   B.7 |
'                   '-----------'  				                  
     	SYMBOL Rx     = C.7
	SYMBOL E      = C.3
	SYMBOL RS     = C.2
	SYMBOL senddata = b0 : SYMBOL sentdata = b0 		
	SYMBOL index    = b4
	
	TABLE   0, ($3,$3,$3,$2,$2,$8,$0,$C,$0,$1,$0,$2,$0,$6)  '(4Bit)(2line/5x8)(Display On)(Clear Display)(Return Home)(Entry Mode Set)
	TABLE  40, ("marks......")
		
	SETFREQ M64	
 	dirsB = %00001111			
 	dirsC = %10111111
 								
IntialiseDisplay: 
      FOR  index = 0 to 13                                               
READTABLE index, senddata : outpinsB = senddata : PULSOUT E,1 ' Initialise LCD/OLED 
 	NEXT index  :  PAUSE 10	
 	 	
Display:
      LOW RS                                                                                                                              
      senddata = 128 : outpinsB = senddata >> 4 : PULSOUT E,1 : outpinsB = senddata : PULSOUT E,1'(128-147) Line 1 Cursor Position
      HIGH RS                                                                                                                              
               
      FOR index = 40 TO 50                                                   
READTABLE index, senddata 
 	   outpinsB = senddata >> 4 : PULSOUT E,1 : outpinsB = senddata : PULSOUT E,1 ' sending characters to line one
 	   pause 500     
 	NEXT index
                                   
 Main:
  SERIN Rx,N9600_64,sentdata
   IF sentdata = 254 THEN Commands
   outpinsB = sentdata >> 4 : PULSOUT E,1 : outpinsB = sentdata : PULSOUT E,1
   GOTO main
   
 Commands:
   SERIN Rx,N9600_64,sentdata
    outpinsB = sentdata >> 4 
    IF outpinsB = $2 then Control 
    LOW RS : PULSOUT E,1 : outpinsB = sentdata : PULSOUT E,1 : HIGH RS
    GOTO Main
    
 Control: 
    SELECT CASE sentdata
    case  $20  low a.0
    case  $21 high a.0
    END SELECT
    GOTO Main
Code:
#picaxe 40x2  ' version B.3 * Testdrive  4bit/20x2 9600 driver * marks
#no_data
SETFREQ M16
PAUSE 1400

Main:
BinToAscii W1,b8,b7,b6,b5,b4
INC W1

serout c.0,n9600_16,(254,192)   ' Command Line 2 Cursor Position

serout c.0,n9600_16,("* *  9600 ",b8,b7,b6,b5,b4)

serout c.0,n9600_16,(254,$21) ' Control A0 high
pause 2000
              
serout c.0,n9600_16,(254,192)   ' Command Line 2 Cursor Position

serout c.0,n9600_16,(" * * 9600 ",b8,b7,b6,b5,b4) 

serout c.0,n9600_16,(254,$20) ' Control A0 low  
pause 2000
goto main
Hi2Cfast
Code:
#picaxe 20X2   '  versions C.0 C.1 C.3     *LCD/OLED driver 4Bit (Hi2C fast)* marks						
#no_data       '    .-----_-----.
#terminal off  '    | V+     0V |
'              ' -->| SI     SO |--> a.0 Control output
'                   | C.7   B.0 |--> LCD DB4
'                   | C.6   B.1 |--> LCD DB5
'                   | C.5   B.2 |--> LCD DB6
'                   | C.4   B.3 |--> LCD DB7
'         LCD E  <--| C.3   B.4 |
'         LCD RS <--| C.2   B.5 |--> SDA Hi2C (2.2k pullup)
'                   | C.1   B.6 |
'                   | C.0   B.7 |--> SCK Hi2C (2.2k pullup)
'                   '-----------'  				
	SYMBOL E      = C.3
	SYMBOL RS     = C.2       				                  	                  
	SYMBOL senddata = b0 : SYMBOL sentdata = b0 		
	SYMBOL index    = b4
	
	TABLE   0, ($3,$3,$3,$2,$2,$8,$0,$C,$0,$1,$0,$2,$0,$6)  '(4Bit)(2line/5x8)(Display On)(Clear Display)(Return Home)(Entry Mode Set)
	TABLE  40, ("marks......")
		
	SETFREQ M64		
 	dirsB = %00001111			
 	dirsC = %10111111
 	 								
IntialiseDisplay: 
      FOR  index = 0 to 13                                               
READTABLE index, senddata : outpinsB = senddata : PULSOUT E,1 ' Initialise LCD/OLED 
 	NEXT index  :  PAUSE 10	
	
 Display:
       LOW RS                                                                                                                              
       senddata = 128 : outpinsB = senddata >> 4 : PULSOUT E,1 : outpinsB = senddata : PULSOUT E,1'(128-147) Line 1 Cursor Position
       HIGH RS                                                                                                                              
               
       FOR index = 40 TO 50                                                   
 READTABLE index, senddata 
  	   outpinsB = senddata >> 4 : PULSOUT E,1 : outpinsB = senddata : PULSOUT E,1 ' sending characters to line one
  	   pause 500     
       NEXT index

HI2CSETUP I2CSLAVE, %10100000
 Hi2C: 
  ptr = 0
  hi2cflag = 0
  SETINTFLAGS %01000000 , %01000000
 
   Main: 
    IF hi2cflag = 0 THEN main
					 					 
Interrupt:
 ptr = 0
 IF @ptrinc = 254 THEN CommandsHi2c
 FOR  ptr = 0 TO hi2clast 
 outpinsB = @ptr >> 4  PULSOUT E,1 : outpinsB = @ptr  PULSOUT E,1 
 NEXT ptr                                      
 GOTO Hi2C
 
 CommandsHi2c:
 outpinsB = @ptr >> 4
 IF outpinsB = $2 THEN ControlHi2c 
 LOW RS : PULSOUT E,1 : outpinsB = @ptr : PULSOUT E,1 : HIGH RS   
 GOTO Hi2C 
 
 ControlHi2c: 
    SELECT CASE @ptr
    case  $20  low a.0
    case  $21 high a.0
    END SELECT
    GOTO Hi2C
Code:
#picaxe 40x2  ' version B.3 * Testdrive  4bit/20x2 Hi2C driver * marks
#no_data
#no_table
SETFREQ M16
HI2CSETUP I2CMASTER,%10100000,I2Cfast_16,I2Cbyte
PAUSE 1400

Main:
BinToAscii W1,b8,b7,b6,b5,b4
INC W1

HI2COUT 0,(254,192) ' Command Line 2 Cursor Position
pause 10
HI2COUT 0,("*    Hi2C ",b8,b7,b6,b5,b4)
pause 40 
HI2COUT 0,(254,$21) ' Control A0 high
pause 2000 
HI2COUT 0,(254,192)
pause 10
HI2COUT 0,(" *   Hi2C ",b8,b7,b6,b5,b4)
pause 40 
HI2COUT 0,(254,$20) ' Control A0 low
pause 2000 

HI2COUT 0,(254,192) ' Command Line 2 Cursor Position
pause 10
HI2COUT 0,("  *  Hi2C ",b8,b7,b6,b5,b4)
pause 40 
HI2COUT 0,(254,$21) ' Control A0 high
pause 2000 
HI2COUT 0,(254,192)
pause 10
HI2COUT 0,("   * Hi2C ",b8,b7,b6,b5,b4)
pause 40 
HI2COUT 0,(254,$20) ' Control A0 low
pause 2000 

goto main
 
Last edited:

marks

Senior Member
#44
Hser OLed/LCD firmware for the 20x2picaxe

The sending code was checked on an LCD it appears Oleds can have more characters per line controller (64) not 40 as assumed
so will appear different than intended will change it when I get around to it. so cut to 40 as I don't have a oled2004 at the moment.


The picaxe 20x2 @ 64mhz can easily keep up while receiving N9600_16
we can send all 80 characters in one go and most pins can be used.
Code:
'#picaxe 40x2  ' version B.3 * Testdrive  4bit/20x2 N9600 driver 
 #picaxe 18m2  ' version 2.D 
#no_data
low c.1                        ' sometimes required to prevent corruption of first serout bytes
SETFREQ M16                     ' or M8 for N9600_8 can be used
PAUSE 3000                      ' allow some time for driver to complete

Main:
serout c.1,n9600_16,(254,128)   ' Command Line 1 Cursor Position (128-147)
serout c.1,n9600_16,("1111111111222222222233333333334444444444") '5555555555666666666677777777778888888888")
 pause 8000                     ' no pauses required after sending any characters just used so you can see the change
 
 serout c.1,n9600_16,(254,$20) ' Control A0 low
 pause 10
 
serout c.1,n9600_16,(254,1)     ' Clear All
pause 1                        ' sometimes required for clear and home to stop missing characters in next line
                                ' if other commands for outputs or messages are created you will need to work the pause required after it.
serout c.1,n9600_16,("marks")
 pause 2000                      ' no pauses required after sending any characters just used so you can see the change

 serout c.1,n9600_16,(254,$21) ' Control A0 high
 pause 10
 
serout c.1,n9600_16,(254,128)  ' Command Line 1 Cursor Position (128-147)
serout c.1,n9600_16,("                                                                                ")
 pause 4000                     ' no pauses required after sending any characters just used so you can see the change
 
GOTO main
For each character we are sending 10 bits
(start ,bit0,bit1,bit2,bit3,bit4,bit5,bit6,bit7, stop) also called a frame or packet.
Usually the time of the stop bit and until we start again, is where we can do our stuff.
When the frequency of the sending picaxe is increased N9600_32 our receiving picaxe has less time to update the display and we may see some mixed results.

If we need a faster baud we can look at using hardware serial. B9600 up to B115200 (but will need to use the dedicated pins.)

HserOut
Code:
 '#picaxe 40x2  ' version B.3 * Testdrive  4bit/20x2  Hserout C.6  
 #picaxe 18m2   ' version 2.D  Hserout B.5
#no_data

SETFREQ M16
PAUSE 1400
HSERSETUP B115200_16, %00010  ' ( normal serial )
PAUSE 3000                      ' allow some time for driver to complete

Main:
hserout 0,(254,128)   ' Command Line 1 Cursor Position (128-147)
 pause 5              ' 19200  38400  57600  115200 not required for 9600
 pause 2              ' required for 18m2
 
hserout 0,("1111111111222222222233333333334444444444") '5555555555666666666677777777778888888888")
 pause 8000                     ' no pauses required after sending any characters just used so you can see the change
 
 hserout 0,(254,$20) ' Control A0 low
 pause 10
 
hserout 0,(254,1)     ' Clear All
 pause 2                    ' required for 18m2
 pause 5                    ' 19200  38400  57600  115200 not required for 9600
 
hserout 0,("marks")
 pause 2000                      ' no pauses required after sending any characters just used so you can see the change
 
 hserout 0,(254,$21) ' Control A0 high
 pause 10

hserout 0,(254,128)  ' Command Line 1 Cursor Position (128-147)
hserout 0,("                                                                                ")
 pause 4000
 
GOTO main
Hser

Code:
#picaxe 20X2   '  version C.3     *LCD/OLED driver 4Bit (Hser)* marks						
#no_data       '    .-----_-----.
#terminal off  '    | V+     0V |
'              ' -->| SI     SO |--> a.0 Control output
'                   | C.7   B.0 |--> LCD DB4
'                   | C.6   B.1 |--> LCD DB5
'                   | C.5   B.2 |--> LCD DB6
'                   | C.4   B.3 |--> LCD DB7
'         LCD E  <--| C.3   B.4 |
'         LCD RS <--| C.2   B.5 |
'                   | C.1   B.6 |<-- HserIN  (10K pulldown)
'        HserOUT <--| C.0   B.7 |
'                   '-----------'  				
	SYMBOL E      = C.3
	SYMBOL RS     = C.2       				                  	                  
	SYMBOL senddata = b0 : SYMBOL sentdata = b0 		
	SYMBOL index    = b4
	
	TABLE   0, ($3,$3,$3,$2,$2,$8,$0,$C,$0,$1,$0,$2,$0,$6)  '(4Bit)(2line/5x8)(Display On)(Clear Display)(Return Home)(Entry Mode Set)
	TABLE  40, ("marks......")
		
	SETFREQ M64		
 	dirsB = %00001111			
 	dirsC = %10111111
 	 								
IntialiseDisplay: 
      FOR  index = 0 to 13                                               
READTABLE index, senddata : outpinsB = senddata : PULSOUT E,1 ' Initialise LCD/OLED 
 	NEXT index  :  PAUSE 10	
	
 Display:
       LOW RS                                                                                                                              
       senddata = 128 : outpinsB = senddata >> 4 : PULSOUT E,1 : outpinsB = senddata : PULSOUT E,1'(128-147) Line 1 Cursor Position
       HIGH RS                                                                                                                              
               
       FOR index = 40 TO 50                                                   
 READTABLE index, senddata 
  	   outpinsB = senddata >> 4 : PULSOUT E,1 : outpinsB = senddata : PULSOUT E,1 ' sending characters to line one
  	   pause 500     
       NEXT index

HSERSETUP B115200_64, %00101  ' ( normal serial in , scratchpad ) 9600  19200  38400  57600  115200

Hser:
  hserptr = 0
  hserinflag = 0
 
   Main: 
    IF hserinflag = 0 THEN main
   ptr = 0 pause 10
  IF @ptrinc = 254 THEN CommandsHser
     ptr =0 pause 50
     do while ptr < hserptr
       outpinsB = @ptr >> 4  PULSOUT E,1 : outpinsB = @ptrinc  PULSOUT E,1
     loop            
   GOTO Hser
 
 CommandsHser:
 outpinsB = @ptr >> 4
 IF outpinsB = $2 THEN ControlHser 
 LOW RS : PULSOUT E,1 : outpinsB = @ptr : PULSOUT E,1 : HIGH RS   
 GOTO Hser 
 
 ControlHser: 
    SELECT CASE @ptr
    case  $20  low a.0
    case  $21 high a.0
    END SELECT
    GOTO Hser
 
Last edited:
Top