skip navigational linksPJRC
Shopping Cart Download Website
Home Products Teensy Blog Forum
You are here: MP3 Player Technical Docs LCD Protocol

PJRC Store
Main Board, $150
LCD & Pushbuttons, $42
LCD/Backlight/PB, $77
IDE Cable, $9
Complete Parts List
MP3 Player
Main Page
Detailed Info
User Photo Gallery
Connecting The Board
Firmware Download
Side Projects
Technical Docs
Freq. Asked Questions
FAQ #2
News And Updates

Display Communication Protocol

PJRC discontinued this product in February 2009, and has not sold these LCDs since that time. PJRC has never sold this LCD via eBay.

If you purchased a similar 24x8 LCD on eBay, that eBay merchant very likely used the open source code published by PJRC, perhaps with their own modifications. They are not affiliated with PJRC. Any adaptor hardware provided with such LCDs is not made by PJRC. Please contact the seller for technical support.

PJRC publishes free technical information and open source code in the hope it will be useful. However, PJRC does not provide technical support for other merchant's products, even when they have utilized free code published on this website.

This page documents the communication protocol used by the 24x8 LCD supplied by PJRC. Most of this information is specific to the firmware provided by PJRC.

If you puchased a LCD from some other source, it may have different firmware, or even a chip that does not contain usable code. PJRC sells a firmware chip that can be used on LCDs obtained from other sources.

About The Display Board

The display circuit board is JW-002, from Earth Computer Tech. The back side of the board has an 80C32 based system with 64k of RAM and a socketed EPROM chip. The clock speed is 11.0592 MHz. The display has two KS0108B controller chips. While these are graphical LCD controller chips, the display itself has grouped the pixels into 5 by 8 pixel blocks, which limits its use for bitmap graphics. Earth's page has the connector pinouts and some other information about the board. Perhaps Earth will provide a schematic and other info on their page in the future. PJRC does not have a schematic for the JW-002 board... we obtained these boards from Earth, so we do not have schematic, layout, or other design data (for students who "need" a schematic, we probably never will since we did not design the board). Our firmware was written based on reverse engineering, and everything that we know about the board is documented in the firmware source code.

When used with the PJRC MP3 player board, the JW-002 is connected by a ribbon cable to a small adaptor board, which contains a MAX232 chip to invert the serial port signals. The Vee voltage of the display is connect to pin 6 of the MAX232. Detailed design information about the pushbutton board is now available.

The 80C32 based system on the JW-002 board provides a socketed EPROM which is mapped only into the 80C32's code space (PSEN signal). No provision exists to write to the EPROM while it is installed on the board. There are two 32 kbyte SRAM chips, which are mapped into data space (RD and WR signals), from 0x0000 to 0xFFEF. The upper 256 bytes of data space are allocated the memory mapped peripherals.

The JW-002 board, as purchased from Earth, comes with an OTP (not reprogrammable) EPROM installed. We believe this is firmware developed by AT&T to use the display in some sort of phone terminal that they no longer make. We know very little about the installed firmware, as the first thing we did was pull their chip and install a chip with PAULMON2.

Firmware for the JW-002 board, which implements the protocol described on this page, can be downloaded from the firmware download page. Beginning with 0.6.2.5, the code that needs to run on the JW-002 board is included in the MP3 player's code distribution. Within the definitions and comments in that code, you can find information about what it known about the JW-002 and instructions for a set of modifications to the JW-002 that allow PAULMON2-based firmware development (instead of burn-and-learn chip swapping).

Techknowman has reverse engineered the JW-002 LCD board and drawn a complete schematic diagram. He also has a simple project that replaces the contrast slider with a digital contrast control.

Connection Between MP3 Player, Display, and Computer/Terminal

The MP3 player allows both a serial interface display board and a PC computer to be connected, but is only has a single UART (serial port), so there are some special considerations needed to allow the MP3 player to communicate with both devices, and to allow the PC to communicate with the display. When the MP3 player sends a byte, both the PC computer and display board will "hear" the communication. When the MP3 player receives a byte, it echo's it, so that whichever device transmitted it will "hear" it echoed, and the other device will have an opportunity to "hear" it as well. This allows communication between the display board and PC.

TODO: draw a diagram

The PC will usually be running a standard terminal emulation program. Most terminal emulation programs are sensitive to control characters. Because of this, the commands used to control the display are designed to avoid containing any control characters, and its responses do not contain any control characters. This also allow all of the display capabilities to be "tried" using an ordinary keyboard and terminal emulation program.

Example Code

Scott Tisdale has provided a simple Visual Basic program which demonstrates how to send many of these commands using Visual Basic.

Sending Data To The Display

There are four types of data that can be sent to the display:
  • Commands - These are always two or more bytes, beginning with byte 0x5C (backslash, '\').
  • Control Characters and Escape Sequences - These are bytes 0 to 31. Many of these will have special functions, and byte 27 initiates an "escape sequence" where one or more characters following perform a command. These should not be send from the MP3 player firmware.
  • Character 0xFF - The character 0xFF is special. It, and the next character that follows it, are always ignored, even within a command. All communication sent by the display board is formatted with 0xFF before each data byte, so that it may be ignored when it is received by the MP3 player firmware's echo.
  • Ordinary Characters - Any other character is drawn onto the display, if the cursor is located within the display area and the board has not been placed in the "ignore input" mode.

Commands

Display Backslash '\'
The backslash '\', ascii code 0x5C, begin a command. In order to display a backslash character, send it twice.
Transmit:
0x5C 0x5C
Receive:
nothing

Display Byte 0 to 31
Some control characters (ascii 0 to 31) have special functions, and it a PC terminal emulation program is also receiving the communication, it may respond to control characters. To cause the board to display characters 0 to 31, send a 0x5C followed by the control character plus 32.
Transmit:
0x5C <byte+32>
Receive:
nothing

Display Byte 127
Ascii code 127 should be displayed by sending this command, because a PC terminal emulation program may respond to this character as a backspace.
Transmit:
0x5C 0x5F;
Receive:
nothing

Display Byte 128 to 159
Characters 128 to 159 should be displayed using these commands, because some PC terminal emulation programs may have undesirable behavior when they receive these characters.
Transmit:
0x5C <byte-32>
Receive:
nothing

Ignore Incoming Characters
All non-command characters following this command are ignored and the image on the display is effectively locked. Control characters and escape sequences are also ignored, but all commands are still received and executed. The MP3 player will usually send this command after it has finished updating the display and needs to send additional information which is intended to be shown in a PC terminal emulator, but not on the LCD display.
Transmit:
0x5C 0x5D
Receive:
nothing

Display Incoming Characters
Return to the default state where all non-command characters are drawn on the screen (if the cursor is within the screen area, of course).
Transmit:
0x5C 0x5B
Receive:
nothing

Clear Display and Set Font
Erase all characters from the display and return the cursor to the upper left corner. The current font is set to the specified font.
Transmit:
0x5C 0x40 <font+32> 0x30
Receive:
nothing

Show Font Preview Page
Show a font preview page, that shows either the first or second half of all the characters of a particular font. The current font is set to whatever font is previews. If the fourth byte is 0x31, bytes 0 to 127 are shown, and if it's 0x32, bytes 128 to 255 are shown.
Transmit:
0x5C 0x40 <font+32> <0x31 or 0x32>
Receive:
nothing

Set Wrap and Scroll Mode
Line wrap causes the cursor to automatically be repositioned at the beginning of the next line when it is advanced beyond the end of a line. When line wrap is off, additional characters are not drawn until the cursor is manually positioned back into the screen's area. Scroll mode causes the entire display to scroll vertically when the cursor is advanced downward beyond the last row of the display. When scroll mode is off, the behavior is determined by the wrap mode. If wrap is on and scroll is off, downward cursor movement beyond the last row causes the cursor to reposition at the top of the screen. If both modes are off, no additional characters are drawn until the cursor is manually repositioned into the screen's area.
Transmit:
0x5C 0x41 <mode>
mode = 0x30: wrap off, scroll off
mode = 0x31: wrap on, scroll off
mode = 0x32: wrap off, scroll on
mode = 0x33: wrap on, scroll on
Receive:
nothing

Position Cursor
Set the cursor to an absolute position. The row and column positions are zero based. For example, to set the cursor to the fourth character on the second row of the display, 0x5C 0x42 0x23 0x21 would be sent.
Transmit:
0x5C 0x42 <column+32> <row+32>
Receive:
nothing

Select Font
Set the current font. The board supports 32 fonts. Setting to unsupported fonts will set to font 0 (the default). The font number is offset by 32, to avoid transmitting control characters as part of the command.
Transmit:
0x5C 0x43 <font+32>
Receive:
nothing

Define Custom Character
Download a custom character to RAM. The character number is sent as two byte ascii hex, followed by a font number (offset by 32), and a 8-byte bitmap. You may write to any font. User defined fonts should be placed in 8 through 31. Low numbered fonts may also be written, but this should generally only be done if the appearance of particular characters needs to be changed. See the LCD Fonts page for images of the fonts included in the display board's firmware. All downloaded font bitmaps are stored in volatile memory and are lost when the board is rebooted.

Transmit:
0x5C 0x44 <char, 2 byte hex> <font+32> <bitmap, 8 bytes>

Example: Changing the appearance of capital "R" (R is ascii 0x52) in font #0:
0x5C 0x44 0x35 0x32 0x20 0x3E 0x39 0x39 0x39 0x3E 0x3A 0x39 0x39
Encoded as an ascii string: "\D52 >999>:99"

Desired GraphicBit EncodingByte Encoding
1 1 1 1 0 0 0 1 1 1 1 1 0 0x3E
1 1 0 0 1 0 0 1 1 1 0 0 1 0x39
1 1 0 0 1 0 0 1 1 1 0 0 1 0x39
1 1 0 0 1 0 0 1 1 1 0 0 1 0x39
1 1 1 1 0 0 0 1 1 1 1 1 0 0x3E
1 1 0 1 0 0 0 1 1 1 0 1 0 0x3A
1 1 0 0 1 0 0 1 1 1 0 0 1 0x39
1 1 0 0 1 0 0 1 1 1 0 0 1 0x39
Receive:
nothing

Read Display Board Identification Byte
Ask the board to return a message that will identify it. Other display boards will return a different code.
Transmit:
0x5C 0x45
Receive:
Version 0 - 0xFF 0xC2
Version 1 - 0xFF 0xC3 "VERSION1"

Move Cursor Left
Transmit:
0x5C 0x46 <offset+32>
Receive:
nothing

Move Cursor Right
Transmit:
0x5C 0x46 <offset+64>
Receive:
nothing

Move Cursor Down
Transmit:
0x5C 0x46 <offset+96>
Receive:
nothing

Move Cursor Up
Transmit:
0x5C 0x46 <offset+112> button = 48 to 59
Receive:
nothing

Configure Pushbutton Auto-Repeat Speed
Transmit:
0x5C 0x47 <button> <config+32>
button = 48 to 59 config = (see code)
Receive:
nothing

Configure Pushbutton Message String
Transmit:
0x5C 0x48 <button> <string, 12 bytes>
button = 48 to 59, sets string when pressed (down) button = 64 to 75, sets strings when released (up) button = 80 to 91, sets strings for auto-repeat string = 12 byte string to send, pad with spaces to 12 bytes, all spaces suppresses printing of the string
Receive:
nothing

Cached update or frame buffer control (protocol version 1 and later only)
This feature allows you reduce flicker on the LCD. Rather than having your characters appear one-at-a-time as they arrive at 19200 baud, you can turn off instant updates. All your writes are then cached to an off-screen buffer. Once your entire update is buffered, you send a command to have a single line or the entire screen quickly updated from the buffer (at the full bus speed of the LCD controller chips). The redraw commands do not alter the update mode, and the mode change commands do not cause redraws.
Transmit:
0x5C 0x49 <command>
command = '0' - '7' redraws one line from buffer. Line (0 - 7) specified by command number. Update mode is not changed.
command = '8' redraws entire display from buffer. Update mode is not changed.
command = '9' turns instant display updates on, writes go to buffer and display (default for version 0 compatibility). Please note, this does not cause a redraw of any buffered data. In most cases, a redraw command should be sent together with this one.
command = ':' turns instant display updates off, writes go to buffer only
Receive:
nothing

External input/output control (protocol version 1 and later only)
Control extra IO on CPU. All signals are active low, electrical ground is active '1', electrical 5V is inactive '0'. (refer to Tom's LCD Modification page for more information)
Transmit:
0x5C 0x4A <command> <state>
command = '0' control LED on front panel
command = '1' control pin 7 on CPU (use with care, may crash non-modified hardware)
command = '2' control pin 8 on CPU (use with care, may crash non-modified hardware)
command = '4' read LED on front panel (will turn led off and always read '0')
command = '5' read pin 7 on CPU (will always read '0' on non-modified hardware)
command = '6' read pin 8 on CPU (will always read '0' on non-modified hardware)
state = '0' for inactive (electrical 5V)
state = '1' for active (electrical ground)
(state is ignored for read, but must be supplied)
Receive:
"IOREAD" <pin> <state>
pin = '0' LED on front panel (always 1)
pin = '1' pin 7 on CPU
pin = '2' pin 8 on CPU
state = '0' for inactive (electrical 5V)
state = '1' for active (electrical ground)

Horizontal scrolling control (protocol version 1 and later only)
Horizontal scrolling of lines works by maintaining a 256 byte buffer for each line. The buffer for a line is filled by enabling buffer fill, writing characters to the buffer and disabling buffer fill. When write is enabled for a buffer the buffer for that line is cleared and scrolling for that line is disabled. When scrolling is enabled for a line, buffer fill is automatically enabled. ie you can end a buffer fill just be enabling scrolling for that line. Font and speed changes are made instantly. The scrolling speed is that same for all lines.

When scrolling is enabled for a line, all other updates to that line are ignored. If the cursor moves to a line with scrolling enabled, all characters will be discarded until the cursor is moved to a non-scrolling line. Scrolling overwrites the frame buffer data for each line it is updating.

Transmit:
0x5C 0x4B <command> <data1> <data2>
command = '0' set the scroll speed -
<data1> determines the speed ('0' - '7'),
<data2> '0' (ignored, but it must be supplied)
command = '1' set the font -
<data1> line number (line+32)
<data2> determines the font (font+32)
command = '2' enable/disable scrolling -
<data1> line number (line+32)
<data2> determines the scrolling state for this line ('1' is enabled, '0' is disabled)
command = '3' buffer fill control -
<data1> line number (line+32)
<data2> start/stop buffer fill ('1' is begin filling buffer with input, '0' is stop)
Receive:
nothing

Clear Row (protocol version 1 and later only)
Transmit:
0x5C 0x4C <row_number+32>
Receive:
nothing

Reserved For Custom User-Added Features
These eight codes are reserved for users to experiment with adding their own features. They will not be defined in the future on this page.
Transmit:
0x5C <0x53 to 0x57> <2 bytes>
0x5C <0x58 to 0x5A> <8 bytes>
Receive:
???

Receiving Events From The Display Board

Control Codes

The board will be able to accept certain control codes, to emulate a subset of VT100 and other common terminal emulation features. The MP3 player firmware should not use these control code, and instead use the commands described above.

CTRL-A
Move cursor to home (upper left corner)
CTRL-H
Move cursor left
CTRL-I
Move cursor to next tab (4 character increments)
CTRL-J
Move cursor down
CTRL-K
Move cursor up
CTRL-L
Clear screen, return cursor to home (upper left corner)
CTRL-M
Return cursor to start of current line
CTRL-U
Move cursor right
ESC [ A (up arrow on PC keyboard)
Move cursor up
ESC [ B (down arrow on PC keyboard)
Move cursor down
ESC [ C (right arrow on PC keyboard)
Move cursor right
ESC [ D (left arrow on PC keyboard)
Move cursor left


MP3 Player, Display Communication Protocol, Paul Stoffregen.
http://www.pjrc.com/tech/mp3/lcd_protocol.html
Last updated: February 23, 2005
Questions, Comments?? <paul@pjrc.com>