HT1621 Display

tim griff

Member
Dear All,

Has anyone tried one of these , I'm struggling understanding the datasheet.

I've found some sample code to use with the Arduino, but don't have the skill to translate.

Any thoughts please
Tim
 

AllyCat

Senior Member
Hi Tim,

I think we may also need a link to the particular LCD display you want to drive, and/or what you want to do with it. The data sheet appears to be for a general-purpose (configurable) "7 segment" driver for 32 segments (i.e. 4 digits), but I'm not clear if that can be multiplied by 4 or 16 by using the four "COM" lines.

It will be necessary to know how the "Segment" lines are mapped in/to the LCD (which should be possible to determine from the Arduino code, if it is relevant) and which characters/digits you want to display: After the 10 regular numbers, the Arduino code appears to offer upper and lower case characters for C and H, but none for G and I to N, etc..

Cheers, Alan.
 

Pongo

Senior Member
Hi Tim,

I think we may also need a link to the particular LCD display you want to drive, and/or what you want to do with it. The data sheet appears to be for a general-purpose (configurable) "7 segment" driver for 32 segments (i.e. 4 digits), but I'm not clear if that can be multiplied by 4 or 16 by using the four "COM" lines.

It will be necessary to know how the "Segment" lines are mapped in/to the LCD (which should be possible to determine from the Arduino code, if it is relevant) and which characters/digits you want to display: After the 10 regular numbers, the Arduino code appears to offer upper and lower case characters for C and H, but none for G and I to N, etc..

Cheers, Alan.
There's some comprehensive Arduino code here which should be helpful. The display appears to be the commonly available HT1621/Arduino ebay module.
 

hippy

Technical Support
Staff member
I've not actually used a HT1621 and it does seem a bit of an unusual device but it will basically be bit banging a data bit stream, the number of bits defined by the first 3-bit command code.

I would throw the C code away, just use it for reference, and design something suited to the PICAXE.

Assuming you would only be writing to the display, setting configuration, setting data to display, that should be fairly easy.

I would start from here ...

Code:
Symbol CS = B.1
Symbol WR = B.2
Symbol RD = B.3
Symbol TX = B.4

#Macro CMD_XXX( bits )
  w0 = bits
  Gosub Send
#EndMacro

#Macro CMD_WRITE( adr, dat )
  ; Data : %101aaaaadddd
  CMD_XXX( %101 * 32 | adr * 16 | dat )
#EndMacro

#Macro CMD_DIGIT( adr, dat )
  ; Data : %101aaaaadddd
  w0 = dat // 10 
  CMD_XXX( %101 * 32 | adr * 16 | w0 )
#EndMacro

#Macro SYS_DIS
  ; Data : %10000000000X
  CMD_XXX( %100000000000 )
#EndMacro

#Macro SYS_EN
  ; Data : %10000000001X
  CMD_XXX( %100000000010 )
#EndMacro

#Macro LCD_OFF
  ; Data : %10000000010X
  CMD_XXX( %100000000100 )
#EndMacro

#Macro LCD_ON
  ; Data : %10000000011X
  CMD_XXX( %100000000110 )
#EndMacro

#Macro TIMER_DIS
  ; Data : %10000000100X
  CMD_XXX( %100000001000 )
#EndMacro

#Macro WDT_DIS
  ; Data : %10000000101X
  CMD_XXX( %100000001010 )
#EndMacro

#Macro TIMER_EN
  ; Data : %10000000110X
  CMD_XXX( %100000001100 )
#EndMacro

#Macro WDT_EN
  ; Data : %10000000111X
  CMD_XXX( %100000001110 )
#EndMacro

#Macro TONE_OFF
  ; Data : %10000001000X
  CMD_XXX( %100000010000 )
#EndMacro

#Macro TONE_ON
  ; Data : %10000001001X
  CMD_XXX( %100000010010 )
#EndMacro

#Macro CLR_TIMER
  ; Data : %10000011XXXX
  CMD_XXX( %100000110000 )
#EndMacro

#Macro CLR_WDT
  ; Data : %100000111XXX
  CMD_XXX( %100000111000 )
#EndMacro

#Macro XTAL_32K
  ; Data : %100000101XXX
  CMD_XXX( %100000101000 )
#EndMacro

#Macro RC_256K
  ; Data : %100000110XXX
  CMD_XXX( %100000110000 )
#EndMacro

#Macro EXT_256K
  ; Data : %100000111XXX
  CMD_XXX( %100000111000 )
#EndMacro

#Macro BIAS_HALF_2
  ; Data : %1000010abX0X
  CMD_XXX( %100001000000 )
#EndMacro

#Macro BIAS_HALF_3
  ; Data : %1000010abX0X
  CMD_XXX( %100001001000 )
#EndMacro

#Macro BIAS_HALF_4
  ; Data : %1000010abX0X
  CMD_XXX( %100001010000 )
#EndMacro

#Macro BIAS_THIRD_2
  ; Data : %1000010abX1X
  CMD_XXX( %100001000010 )
#EndMacro

#Macro BIAS_THIRD_3
  ; Data : %1000010abX1X
  CMD_XXX( %100001001010 )
#EndMacro

#Macro BIAS_THIRD_4
  ; Data : %1000010abX1X
  CMD_XXX( %100001010010 )
#EndMacro

#Macro TONE_4K
  ; Data : %100010XXXXXX
  CMD_XXX( %100010000000 )
#EndMacro

#Macro TONE_2K
  ; Data : %100011XXXXXX
  CMD_XXX( %100011000000 )
#EndMacro

#Macro IRQ_DIS
  ; Data : %100100X0XXXX
  CMD_XXX( %100100000000 )
#EndMacro

#Macro IRQ_EN
  ; Data : %100100X1XXXX
  CMD_XXX( %100100010000 )
#EndMacro

#Macro F1
  ; Data : %100101XXfffX
  CMD_XXX( %100101000000 )
#EndMacro

#Macro F2
  ; Data : %100101XXfffX
  CMD_XXX( %100101000010 )
#EndMacro

#Macro F4
  ; Data : %100101XXfffX
  CMD_XXX( %100101000100 )
#EndMacro

#Macro F8
  ; Data : %100101XXfffX
  CMD_XXX( %100101000110 )
#EndMacro

#Macro F16
  ; Data : %100101XXfffX
  CMD_XXX( %100101001000 )
#EndMacro

#Macro F32
  ; Data : %100101XXfffX
  CMD_XXX( %100101001010 )
#EndMacro

#Macro F64
  ; Data : %100101XXfffX
  CMD_XXX( %100101001100 )
#EndMacro

#Macro F128
  ; Data : %100101XXfffX
  CMD_XXX( %100101001110 )
#EndMacro

#Macro TEST
  ; Data : %10011100000X
  CMD_XXX( %100111000000 )
#EndMacro

#Macro NORMAL
  ; Data : %10011100011X
  CMD_XXX( %100111000110 )
#EndMacro

Init:
  ;                      Datasheet      C-Version
  SYS_EN            ; %100-0000-0001-X    0x02 
  RC_256K           ; %100-0001-10XX-X    0x30
  BIAS_THIRD_4      ; %100-0010-10X1-X    0x52
  LCD_ON            ; %100-0000-0011-X    0x06

Main:
  CMD_WRITE( 0, 9 ) ; %101-aaaa-addd-d
  CMD_WRITE( 1, 8 )
  CMD_WRITE( 2, 7 )
  CMD_WRITE( 3, 6 )
  CMD_WRITE( 4, 5 )
  CMD_WRITE( 5, 4 )
  CMD_WRITE( 6, 3 )
  CMD_WRITE( 7, 2 )
  CMD_WRITE( 8, 1 )

  Pause 5000

MainLoop:
  w2 = 12345
  Do
    CMD_DIGIT( 0, w2 / 10000 )
    CMD_DIGIT( 1, w2 / 1000  )
    CMD_DIGIT( 2, w2 / 100   )
    CMD_DIGIT( 3, w2 / 10    )
    CMD_DIGIT( 4, w2         )
    Pause 1000
    w2 = w2 + 1
  Loop

Send:
  High CS
  High WR
  High RD
  Low  CS
  ; Maximum of 16 bits output
  b2 = 16
  ; Left align bits
  Do While w0 < $8000
    w0 = w0 * 2
    b2 = b2 - 1
  Loop
  ; Command in top three bits
  b3 = w0 / $2000
  Select Case b3
    Case %100, %101 ;Command, Write
      Do
        Low  WR
        If w0 >= $8000 Then
          High TX
        Else
          Low  TX
        End If
        w0 = w0 * 2
        High WR
        b2 = b2 - 1
      Loop while b2 > 0
  End Select
  High CS
  Return
That doesn't include all the commands supported and the actual 'Main:' code is just guessing.

Updated to include all commands, and initialisation as per the C example code.

All untested, and particularly not sure the digits handling code will be right, but something like that.
 
Last edited:
Top