Previous Section

8. HD61830(B) Instruction Set

The following is a summary of available instructions for use with the HD61830(B).

Table 8.0: HD61830(B) Instruction Set

R/Not W RS DB7
MSB
DB6 DB5 DB4 DB3 DB2 DB1 DB0
LSB
Function
0 1 0 0 0 0 0 0 0 0 Set Mode Control Register
0 0 0 0 Mode Control data Mode Control data
0 1 0 0 0 0 0 0 0 1 Set Character Pitch Register
0 0 (VP-1) binary 0 (HP-1) binary Vert./Horiz. Pitch data
0 1 0 0 0 0 0 0 1 0 Set Horizontal Count Register
0 0 0 (HN-1) binary Horizontal Count data
0 1 0 0 0 0 0 0 1 1 Set Multiplex Ratio Register
0 0 0 (NX-1) binary Multiplex ratio data (1/Duty-1)
  1 0 0 0 0 0 1 0 0 Set Cursor Position Register
0 0 0 0 0 0 (CP-1) binary Cursor Position data
0 1 0 0 0 0 1 0 0 0 Set Lower Dis. Start Addr Reg
0 0 (Low order Display Start Address) binary Lower Display Start Addr. data
0 1 0 0 0 0 1 0 0 1 Set Upper Dis. Start Addr Reg
0 0 (High order Display Start Address) binary Upper Display Start Addr. data
0 1 0 0 0 0 1 0 1 0 Set Lower Cursor Addr Reg
0 0 (Low order Cursor Address) binary Lower Cursor Address data
0 1 0 0 0 0 1 0 1 1 Set Upper Cursor Addr Reg
0 0 (High order Cursor Address) binary Upper Cursor Address data
0 1 0 0 0 0 1 1 0 0 Write-VRAM Instruction
0 0 MSB (Character code or bit-map data) LSB Display data
0 1 0 0 0 0 1 1 0 1 Read-VRAM Instruction
1 0 MSB (Character code or bit-map data) LSB Display data
0 1 0 0 0 0 1 1 1 0 Bit Clear Instruction
0 0 0 0 0 0 0 (NB-1) binary Bit Address
0 1 0 0 0 0 1 1 1 1 Bit Set Instruction
0 0 0 0 0 0 0 (NB-1) binary Bit Address
1 1 BF * * * * * * * Read BUSY FLAG
                     

Note:

  1. * = DON'T CARE
  2. Read the status of the Busy Flag before each new instruction is sent to the HD61830(B). If the HD61830(B) Busy Flag is set (BF=1) then the HD61830(B) is busy processing the previous instruction. If a new instruction is sent to the HD61830(B) while the Busy Flag, BF=1, then that command shall be ignored by the HD61830(B).
  3. Vertical Character Pitch, VP:0 < (VP-1) < 15
  4. Horizontal Character Pitch,HP:5 < (HP-1) < 7
  5. Horizontal Character Count, HN:HN < 128, HN must be an even integer.
  6. Multiplex Ratio, NX: NX=1/Duty, NX < 128

8.1 Mode Control Register

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 0 0 0 0 Set Mode Control Register
0 0 0 0 D5 D4 D3 D2 D1 D0 Mode Control data
        | | | | | 0 HD61830(B) Internal CG ROM
        | | | | | 1 External CG ROM
        | | | | 0 -- Character mode
        | | | | 1 -- Graphics mode
        | | 0 0 -- -- Cursor OFF
        | | 0 1 -- -- Cursor ON
        | | 1 0 -- -- Cursor OFF Character Blink
        | | 1 1 -- -- Cursor blank
        | 0 -- -- -- -- Slave Mode
        | 1 -- -- -- -- Master Mode
        0 -- -- -- -- -- Display OFF
        1 -- -- -- -- -- Display ON

The Mode Control register sets the operating mode for the HD61830(B). It controls the character/graphics mode, cursor, on/off/blink, master/slave and display on/off. When D1 is set to 1 and D0, D2 and D3 are set to 0, the HD61830(B) is set to graphics mode and the character generator and cursor functions are disabled.

Most displays and controller cards use only one HD61830 so D4=1. The LM1006GC is the exception as two HD61830 are used; one configured as the slave (D4=0) and the other as the master (D4=1).

8.2 Character Pitch Register

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 0 0 0 0 Set Character Pitch Register
0 0 (VP-1) binary 0 (HP-1) binary Vert./Horiz. Pitch data

Character Mode:VP and HP set the horizontal and vertical size of each character cell. To display the 5x11 font stored in the CG-ROM set VP=12 and HP=6. That is set the Character Pitch register to B5H. If displaying only the 5x7 font then set VP=8 and HP=6. That is set the Character Pitch register to 75H. A value in the range of 1 to 16 may be used for VP. A value in the range of 6 to 8 may be used for HP. Refer to section 9.0 for pictorial definitions of VP and HP.

Graphics Mode:VP has no meaning in Graphics mode and may be set to any value. HP should be set to 8. That is set Character Pitch register to 07H for Graphics mode.

8.3 Horizontal Count Register

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 0 0 1 0 Set Horizontal Count Instruction
0 0 0 (HN-1) binary Horizontal Count data

Character Mode: This register sets the number of horizontal characters that can be displayed on the LCD. The character width is defined by HP in the Character Pitch Register (Section 8.2).

Graphics Mode: This register sets the number of horizontal bytes that can be displayed on the LCD. For graphics mode, it is best to set HP=8.

If the total number of horizontal dots on the LCD screen is n then:

HN = n /HP

Note: HN must be an even integer value.in the range 2 < HN < 128

For example:If using HD61830(B) to control a 64x240 LCD screen in Character Mode, with HP=6 then set HN=28H. That is, write 27H into Horizontal Count register.

8.4 Multiplex Ratio Register (1/Duty)

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 0 0 1 1 Set Multiplex Ratio Register
0 0 0 (NX-1) binary Multiplex ratio data [(1/Duty)-1]

Set NX to the Duty cycle ratio of the LCD being used. NX should be in the range 1 < NX < 128.

For example: for a 1/64 duty LCD screen set NX=64 and write 3FH into Multiplex Ratio register.

8.5 Cursor Position Register

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 0 1 0 0 Set Cursor Position Register
0 0 0 0 0 0 (CP-1) binary Cursor Position data

In Character Mode, CP indicates the position of the cursor within the character cell defined by VP and HP in the Character Pitch register (Section 8.2). The horizontal width of the cursor is equal to HP. A value of 1 to 16 may be set for CP. If CP > VP no cursor will be displayed. If CP < VP the cursor has higher priority and the cursor shall be written over the top of the character on the LCD screen. CP=1 means cursor will appear on top row of character cell; if CP=VP then cursor will appear on bottom row of character cell.

For example:To display a cursor underneath a 5x7 character, set CP=8. That is write 07H into Cursor Position register. To display a cursor underneath a 5x11 character, set CP=12. That is write 0BH into Cursor Position register.

8.6 Display Start Address Registers

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 1 0 0 0 Set Lower Dis. Start Addr Reg
0 0 (Low order Display Start Address) binary Lower Display start Addr. data
0 1 0 0 0 0 1 0 0 1 Set Upper Dis. Start Addr Reg
0 0 (High order Display Start Address) binary Upper Display Start Addr. data

The High and Low order Display Start Address indicates a VRAM address at which the data displayed at the top left corner of the LCD screen is stored.

Character Mode:Set DB7~DB4 = 0, for High order Display Start Address. Only DB3~DB0 is valid for High order Display Start Address in the Character Mode. That is a value in the range of 0000H to 0FFFH may be written into the High/Low order Display Start Address registers for the HD61830(B) Character Mode.

Graphics Mode:All 16 bits of the High/Low order Display Start Address register are valid for the Graphics Mode of the HD61830(B). A value in the range 0000H to FFFFH may be written into the High/Low order Display Start Address registers. However bear in mind that not all LCD modules or controller cards have this much addressable RAM on-board. Refer to individual LCD module specifications for size of addressable VRAM.

The Display Start Address registers are very useful when implementing scrolling both horizontally and vertically. The Display Start Address may be incremented or decremented by the value HN (section 8.3) to scroll up or down by one row of dots in the Graphics mode or by one character row (set by VP) in the Character mode. By incrementing/decrementing the Display Start Address by one will cause the LCD screen to shift horizontally left/right by the number of dots set by the value HP (section 8.2) as shown by below.

For Example:

A B C -- -- --   D     A B C -- -- --   D E  
E F G         H       F G         H I  
I |           |         |           |  
                                       
  |           |         |           |  
                                       
  |           |         |           |  
                                    J  
J K L -- -- --   M       K L -- -- --   M N  
N O P -- -- --   Q R S   O P -- -- --   Q R S

Before Incrementing Display Start Address.... After Incrementing Display Start Address....

8.7 Cursor Address Register ( VRAM write address register)

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 1 0 1 0 Set Lower Cursor Addr Reg
0 0 (Low order Cursor Address) binary Lower Cursor Address data
0 1 0 0 0 0 1 0 1 1 Set Upper Cursor Addr Reg
0 0 (High order Cursor Address) binary Upper Cursor Address data

The Cursor Address registers set the address for reading/writing display data to the VRAM. Always write to the Low Order Cursor Address register first followed by the High order Cursor Address register. The High order Cursor Address register may be updated independently from the Low order Cursor Address register; however if the Low order Cursor Address register is updated then the High order Cursor Address register must also be updated directly afterwards.

The Cursor Address is automatically incremented by +1 after each successive Write-VRAM, Read-VRAM, Bit Set or Bit Clear instruction.

Character Mode: Set DB7~DB4 = 0, for High order Cursor Address. Only DB3~DB0 is valid for High order Cursor Address in the Character Mode. That is a value in the range of 0000H to 0FFFH may be written into the High/Low order Display Start Address registers for the HD61830(B) Character Mode.

Graphics Mode: All 16 bits of the High/Low order Cursor Address register are valid for the Graphics Mode of the HD61830(B). A value in the range 0000H to FFFFH may be written into the High/Low order Cursor Address registers. However bear in mind that not all LCD modules have this much addressable RAM on-board. Refer to individual LCD module specifications for size of addressable VRAM.

8.8 Write Data to VRAM Instruction

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 1 1 0 0 Write-VRAM Instruction
0 0 MSB (Character code or bit-map data) LSB Display data

Character Mode:This instruction will load the character code data into VRAM at the address specified by the current value stored in the Cursor Address register (section 8.7). The Cursor Address register will increment by +1 after each successive Write-VRAM instruction. Therefore to write DENSITRON to VRAM address 01FFH, write the following sequence of commands to the HD61830(B):

STEP # 1 2 3 4 5 6 7 8 9 10 11 12 13 14
DB7~DB0 0A FF 0B 01 0C 44 45 4E 53 49 54 52 4F 4E
RS 1 0 1 0 1 0 0 0 0 0 0 0 0 0
R/Not W 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Note:Check Busy Flag (BF) before steps 1, 3, and 5. All values are hexadecimal.

In order to move the word DENSITRON so that it is visible at the top left hand corner of the LCD screen set the Display Start Address register to 01FFH (section 8.6). Note that if the character code written to VRAM is not recognized by the CG-ROM then a blank character will be displayed on the LCD screen (Refer to section 14.0).

Graphics Mode: This instruction will load a byte of data into VRAM at the address specified by the current value stored in the Cursor Address (section 8.7). The Cursor Address register will increment by +1 after each successive Write-Vram instruction. The least significant bit (LSB) of each byte written to VRAM correspondes to the left most dot on the LCD screen (See section 10.0)

8.9 Read data from VRAM Instruction

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 1 1 0 1 Read-VRAM Instruction
1 0 MSB (Character code or bit-map data) LSB Display data

This instruction outputs the data stored in the VRAM at the address immediately preceding the current Cursor Address. The Cursor Address is incremented by +1 after each successive Read-VRAM instruction. To read the VRAM data at the current Cursor Address it will be necessary to do a dummy Read-VRAM instruction so that the Cursor address is incremented by +1 before issuing the next read instruction which will put valid data on the data bus. For example assume DENSITRON is stored in VRAM starting at address 01FFH. The following sequence will read the data stored at addresses 01FFH to 0208H. Note the dummy read at step number 6. It is important to remember to make one dummy read when reading data after setting the Cursor Address register.

STEP # 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
DB7~DB0 0A FF 0B 01 0D * 44 45 4E 53 49 54 52 4F 4E
RS 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0
R/Not W 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1

Note: Check Busy Flag (BF) before steps 1, 3, and 5. All values are hexadecimal.

8.10 Bit Clear and Bit Set Instructions

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
0 1 0 0 0 0 1 1 1 O Bit Clear Instruction
0 0 0 0 0 0 0 (NB-1) binary Bit Address
0 1 0 0 0 0 1 1 1 1 Bit Set Instruction
0 0 0 0 0 0 0 (NB-1) binary Bit Address

The Clear/Set Bit instructions reset/set 1 bit in a byte of VRAM data to 0 or 1, respectively. The position of the bit in a byte is defined by NB. NB=1 refers to the LSB, D0. NB=8 refers to the MSB, D7.

The Cursor Address is automatically incremented by +1 after execution of these instructions. For example; to clear bit D4 of address 01FFH and set bits D1 and D6 of 0200H use the following sequence:

STEP # 1 2 3 4 5 6 7 8 9 10 11 12 13 14
DB7~DB0 0A FF 0B 01 0E 04 0F 01 0A 00 0B 02 0F 06
RS 1 0 1 0 1 0 1 0 1 0 1 0 1 0
R/Not W 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Note: Check Busy Flag (BF) before steps 1, 3, 5, 7, 9 and 11. All values are hexadecimal.

8.11 Read BUSY FLAG

R/Not W RS DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Function
1 1 BF * * * * * * * Read BUSY FLAG

This instruction is used to check whether the HD61830(B) is in the BUSY state or not. The BUSY FLAG (BF) should be checked before initiating any instruction to the HD61830(B), except when data is written in the register (RS=1).

BF=1:HD61830(B) is BUSY
BF=0:HD61830(B) is not BUSY

Table 8.12: Busy Signal Timing

Function BUSY
  BUSY FLAG Min. Max.
Write Instruction (RS=1) NOT SET - 1µs
Write Data (RS=0) SET tCL2 2 x tCL2
Read/Write VRAM SET 2 x tCL2 (2 + HP)tCL2
BIT Set/Clear SET (2 + HP)tCL2 2(HP+1)tCL2

Note: A safety factor of 3 times the maximum BUSY time indicated above should be used if the Busy Flag is not polled by the MPU before each instruction is sent to the HD61830(B).


Next Section