OpenGround – Part 5 – driving the HSG12864 Display (ST7567 controller)

By | September 18, 2016

This is the 5th post of my series documenting the development of a custom firmware for the FS-i6s transmitter. In my previous post i showed you how to run the gdb on the remote target to step through your custom code on a stm32f0. This time we will set up our code to drive the FS-i6s‘ LC-Display.

HSG12864 Display

As written in the first post of this series, the display part number is written on the flat ribbon cable. It is a HSG12864 display using a Sitronix ST7567 controller. Lucky for us, the datasheet is available online. The display is connected in 8-Bit mode with data lines D0..D7 and uses 5 additional control signals (labeled RW, RST, RS, RD, and CS on the pcb, see the pinout on post 1).

When browsing the datasheet you will notice that these names do not match the naming scheme of the manual. Flysky called them a bit different, but that was easy to figure out.


Before initializing the display it is recommended to reset the display by forcing RST low for at least 5us. Afterwards a special init sequence has to be executed. Send:

  1. CMD_RESET to execute a software reset
  2. CMD_DISPLAY_OFF to switch it off during init
  3. CMD_MODE_RAM to enable normal ram operation
  4. CMD_BIAS_1_7 to configure the biasing (found by try’n’error, 1/9th does not work)
  5. CMD_COM_NORMAL to set up normal COM numbering
  6. CMD_COM_SEG_INVERSE to inverse the SEG numbering (display is mounted upside-down)
  7. CMD_POWERCTRL_ALL_ON to switch on all voltage generators
  8. CMD_REG_RATIO_011 (seems to work fine, has something to do with contrast)
  9. CMD_EV followed by a byte to set the contrast (we use 35)
  12. CMD_SET_COL_LO + 0
  13. CMD_SET_COL_HI + 0

Thats it, the display is initialized and can receive data. Unfortunately the datasheet does not give any timing information. However it seems to work fine without any wait cycles before/after toggling the strobe lines.


We will use a framebuffer on the STM32 and transfer it to the LCD when necessary. There is enough RAM for that and it is faster/easier to use than reading back the displays’ DRAM for read/modify operations. As this is a 1-bit display the framebuffer consists of 128*64/8 = 1024 bytes.

Screen routines

For drawing on the screen we will use the fast routines from the openglcd library. They were slightly modified and can be found in the file screen.c. They support basic drawing and rendering of text to the screen.

Console debugging

For debugging it is quite convenient to be able to put some debug text on the screen. The file console.c implements a basic 8 by 21 chars console screen. It features newline handling, clearing etc. It can be used for sending debug information e.g. by calling debug(“text”) or debug_put_uint8(123) etc (see debug.c).



Leave a Reply

Your email address will not be published. Required fields are marked *