Positron Compiler Documentation

Toshiba_Command

Positron8 · Revision 4.0.6.5 · PDF pages 288–291

Toshiba_Command Command, Value

Send a command with or without parameters to a Toshiba T6963 graphic LCD.

Command can be a constant, variable, or expression, that contains the command to send to the LCD. This will always be an 8-bit value. Value can be a constant, variable, or expression, that contains an 8-bit or 16-bit parameter associated with the command. An 8-bit value will be sent as a single parameter, while a 16-bit value will be sent as two parameters. Parameters are optional as some commands do not require any. Therefore if no parameters are included, only a command is sent to the LCD.

Because the size of the parameter is vital to the correct operation of specific commands, you can force the size of the parameter sent by issuing either the text “Byte” or “Word” prior to the parameter’s value.

Toshiba_Command $C0, Byte $FF01  ' Send the low byte of the 16-bit value.
Toshiba_Command $C0, Word $01   ' Send a 16-bit value regardless.

The explanation of each command is too lengthy for this document, however they can be found in the Toshiba T6963 datasheet. The example program shown below contains a condensed list of commands.

' Pan two pages of text left and right on a 128x64 Toshiba T6963 graphic LCD
  Device = 18F452
  Declare LCD_Type = Toshiba         ' Use a Toshiba T6963 graphic LCD
'
' LCD interface pin assignments
'
  Declare LCD_DTPort = PORTD         ' LCD’s Data port
  Declare LCD_WRPin = PORTE.2        ' LCD’s WR line
  Declare LCD_RDPin = PORTE.1        ' LCD’s RD line
  Declare LCD_CEPin = PORTE.0        ' LCD’s CE line
  Declare LCD_CDPin = PORTA.1        ' LCD’s CD line
  Declare LCD_RSTPin = PORTA.0        ' LCD’s Reset line (Optional)
'
' LCD characteristics
'
  Declare LCD_Text_Pages = 2         ' Choose two text pages
  Declare LCD_RAM_Size = 8192        ' Amount of RAM the LCD contains
  Declare LCD_X_Res = 128             ' LCD’s X Resolution
  Declare LCD_Y_Res = 64             ' LCD’s Y Resolution
  Declare LCD_Font_Width = 6         ' The width of the LCD’s font
  Declare LCD_Text_Home_Address = 0  ' Text RAM starts at address 0
View original PDF page 288Open page in PDFOriginal PDF page 288
' LCD Display Constants: -
' Register set commands:
  Symbol T_Cursor_Pointer_Set = $21   ' Cursor Pointer Set
' Offset Register Set (CGRAM start address offset)
  Symbol T_OFFset_Reg_Set  = $22
  Symbol T_Addr_Pointer_Set = $24     ' Address Pointer Set
' Control Word Set commands:
  Symbol T_Text_Home_Set = $40        ' Text Home Address Set
  Symbol T_Text_Area_Set = $41        ' Text Area Set
  Symbol T_Graph_Home_Set = $42       ' Graphics Home address Set
   Symbol T_Graph_Area_Set = $43       ' Graphics Area Set
' Mode Set commands:
   Symbol T_or_Mode = $80             ' or mode
  Symbol T_xor_Mode = $81             ' xor mode
  Symbol T_and_Mode = $83             ' and mode
  Symbol T_Text_ATTR_Mode = $84       ' Text Attribute mode
  Symbol T_INT_CG_Mode = $80         ' Internal CG ROM mode
  Symbol T_EXT_CG_Mode = $88         ' External CG RAM mode
' Display Mode commands (or together required bits):
  Symbol T_DISPLAY_OFF = $90         ' Display off
  Symbol T_BLINK_ON = $91             ' Cursor Blink on
  Symbol T_Cursor_ON = $92          ' Cursor on
  Symbol T_Text_ON = $94             ' Text mode on
  Symbol T_Graphic_ON = $98          ' Graphic mode on
  Symbol T_Text_and_GRAPH_ON = $9C   ' Text and graphic mode on
' Cursor Pattern Select:
  Symbol T_Cursor_1Line = $A0        ' 1 line cursor
  Symbol T_Cursor_2Line = $A1        ' 2 line cursor
  Symbol T_Cursor_3Line = $A2        ' 3 line cursor
  Symbol T_Cursor_4Line = $A3        ' 4 line cursor
  Symbol T_Cursor_5Line = $A4        ' 5 line cursor
  Symbol T_Cursor_6Line = $A5        ' 6 line cursor
  Symbol T_Cursor_7Line = $A6        ' 7 line cursor
  Symbol T_Cursor_8Line = $A7        ' 8 line cursor
' Data Auto Read/Write:
  Symbol T_Data_AUTO_WR = $B0        ' Data write with auto increment of address
  Symbol T_Data_AUTO_RD = $B1        ' Data read with auto increment of address
  Symbol T_AUTO_Data_Reset = $B2    ' Disable auto read/write
' Data Read/Write:
  Symbol T_Data_WR_Inc = $C0         ' Data write and increment address
  Symbol T_Data_RD_Inc = $C1         ' Data read and increment address
  Symbol T_Data_WR_Dec = $C2         ' Data write and decrement address
  Symbol T_Data_RD_Dec = $C3         ' Data read and decrement address
  Symbol T_Data_WR = $C4             ' Data write with no address change
  Symbol T_Data_RD = $C5             ' Data read with no address change
' Screen Peek:
  Symbol T_Screen_Peek = $E0         ' Read the display
' Screen Copy:
  Symbol T_Screen_Copy = $E8         ' Copy a line of the display
' Bit Set/Reset (or with bit number 0-7):
  Symbol T_Bit_Reset = $F0          ' Pixel clear
  Symbol T_Bit_Set = $F8             ' Pixel set
View original PDF page 289Open page in PDFOriginal PDF page 289
' Create two variables for the demonstration
  Dim Pan_Loop as Byte      ' Holds the amount of pans to perform
  Dim Ypos as Byte          ' Holds the Y position of the displayed text
'
' The Main program loop starts here
'
  DelayMs 100               ' Wait for the LCD to stabilise
  Cls                      ' Clear and initialise the LCD
'
' Place text on two screen pages
'
  For Ypos = 1 to 6
     Print At Ypos, 0, "  THIS IS PAGE ONE      THIS IS PAGE TWO"
  Next
'
' Draw a box around the display
'
  Line 1, 0, 0, 127, 0          ' Top line
  LineTo 1, 127, 63             ' Right line
  LineTo 1, 0, 63               ' Bottom line
  LineTo 1, 0, 0                  ' Left line
'
' Pan from one screen to the next then back
'
  While                         ' Create an infinite loop
     For Pan_Loop = 0 to 22
       '
       ' Increment the Text home address
       '
       Toshiba_Command T_Text_Home_Set, Word Pan_Loop
       DelayMs 200
     Next
     DelayMs 200
     For PAN_Loop = 22 to 0 Step –1
       '
       ' Decrement the Text home address
       '
       Toshiba_Command T_Text_Home_Set, Word Pan_Loop
       DelayMs 200
     Next
     DelayMs 200
  Wend                           ' Do it forever

When the Toshiba LCD’s Declares are issued within the BASIC program, several internal variables and constants are automatically created that contain the Port and Bits used by the actual interface and also some constant values holding valuable information concerning the LCD’s RAM boundaries and setup. These variables and constants can be used within the BASIC or Assembler environment. The internal variables and constants are: -

Variables.

_ _LCD_DTPortThe Port where the LCD’s data lines are attached.
_ _LCD_WRPortThe Port where the LCD’s WR pin is attached.
_ _LCD_RDPortThe Port where the LCD’s RD pin is attached.
_ _LCD_CEPortThe Port where the LCD’s CE pin is attached.
_ _LCD_CDPortThe Port where the LCD’s CD pin is attached.
_ _LCD_RSTPortThe Port where the LCD’s RST pin is attached.
View original PDF page 290Open page in PDFOriginal PDF page 290

Constants.

_ _LCD_TypeThe type of LCD targeted. 0 = Alphanumeric, 1 = KS0108, 2 = Toshiba.
_ _LCD_WRPinThe Pin where the LCD’s WR line is attached.
_ _LCD_RDPinThe Pin where the LCD’s RD line is attached.
_ _LCD_CEPinThe Pin where the LCD’s CE line is attached.
_ _LCD_CDPinThe Pin where the LCD’s CD line is attached.

_ _LCD_RSTPin The Pin where the LCD’s RST line is attached.

_ _LCD_Text_PagesThe amount of TEXT pages chosen.
_ _LCD_Graphic_PagesThe amount of Graphic pages chosen.
_ _LCD_RAM_SizeThe amount of RAM that the LCD contains.
_ _LCD_X_ResThe X resolution of the LCD. i.e. Horizontal pixels.
_ _LCD_Y_ResThe Y resolution of the LCD. i.e. Vertical pixels.
_ _LCD_Font_WidthThe width of the font. i.e. 6 or 8.
_ _LCD_Text_AreaThe amount of characters on a single line of TEXT RAM.
_ _LCD_Graphic_AreaThe amount of characters on a single line of Graphic RAM.
_ _LCD_Text_Home_AddressThe Starting address of the TEXT RAM.
_ _LCD_Graphic_Home_AddressThe Starting address of the Graphic RAM.
_ _LCD_CGRAM_Home_AddressThe Starting address of the CG RAM.
_ _LCD_End_Of_Graphic_RAMThe Ending address of Graphic RAM.
_ _LCD_CGRAM_OFFsetThe Offset value for use with CG RAM.

Notice that each name has TWO underscores preceding it. This should ensure that duplicate names are not defined within the BASIC environment.

It may not be apparent straight away why the variables and constants are required, however, the Toshiba LCDs are capable of many tricks such as panning, page flipping, text manipulation etc, and all these require some knowledge of RAM boundaries and specific values relating to the resolution of the LCD used.

See also : LCDRead, LCDWrite, Pixel, Plot, Toshiba_UDG,UnPlot. See Print for circuit.

View original PDF page 291Open page in PDFOriginal PDF page 291