HD44780 Protocol Analyzer

One of the best investments I have made recently has been on an 8 channel Saleae Logic analyzer.  The 16 channel unit was unfortunately outside of my budget.  The current version of the software that drives the logic analyzer is Logic 1.1.15.  It comes with multiple protocol analyzers for serial, parallel, I2C and others.  While integrating an LCD display based on the ubiquitous HD44780 to an ATTINY2313 microcontroller, I needed to debug the initialization sequence of the driver I was using.  Using the parallel protocol analyzer that comes with the Logic software can do the job, but requires painful analysis of each line and going back and forth to the data sheet to translate hex codes to commands.  As a result of this effort I have created a HD44780 protocol analyzer for the Saleae Logic/Logic 16 products.  The rest of this post documents the features of the protocol analyzer and how to install it and take it for a quick spin.

Analyzer Features

The HD44780 Protocol Analyzer supports three modes of analysis in order to balance the type of device you have (Logic or Logic 16) with the different programming modes of the HD44780.  The 11 bit mode, requires 8 channels for data and 3 channels for control.  This mode is only supported in the Logic16 device, since it requires 11 channels.  It analyzes communication with the HD44780 using 8 channels for data.

Figure 1 – 11 bit mode

The 8 bit mode, uses 3 channels for control and 5 channels to supports analysis of 8 channels of data.  In this mode the first 3 bits of the data byte are not captured.  It allows owners of the Logic (8 channels) device to operate in virtual 11 bit mode.  The analyzer compensates for the missing three bits by displaying possible combinations for the captured data.  For instance, while sending the letter ‘A’, binary 01000001, to the HD44780, the analyzer only sees 01000.  It performs all the combinations for the three missing bits and when displaying the message for this data it shows Write(@,A,B,C,D,E,F,G).  This mode is selected by indicating the first three channels of data are ‘None’ in the configuration screen.  This mode is supported in both the Logic and Logic 16 devices.

Figure 2 – 8 bit mode

The 7 bit mode, uses 3 channels for control and 4 channels for data.  This mode is supported in both the Logic and Logic 16 devices and correspond the 4 bit data mode of the HD44780.  This mode is selected by indicating the first four channels of data are ‘None’ in the configuration screen.

Figure 3 – 7 bit mode

The position within the enable pulse where the signal for all channels is measured can be controlled between 0 and 99%.  This has come handy while analyzing code that checks for the busy flag in a tight loop as opposed to providing multiple requests to read the busy flag. The analyzer can generate three types of test patterns.  An initialization sequence, the text “The Quick Brown Fox Jumps Over The Lazy Dog” or you can type your own text in the provided text box.  These data generation options are helpful while testing the analyzer without the Logic or Logic 16 connected to the computer.  Let’s install the analyzer and perform a quick test.

Installation

The binary file and source code are located at Codeplex in the HD44780 Protocol Analyzer project.  Download the binary file from the download area, unzip it  and copy to HD44780Analyzer.dll to the Analyzer directory of the Logic 1.1.15 installation.  In my Windows 7 PC this directory is located at “C:\Program Files\Saleae LLC\Analyzers”.  Note this release of the analyzer is only for windows.  Porting it to Linux and Mac should not be a complicated task.  Once you have copied the file, launch the Logic 1.1.15 software and under the Analyzer menu on the right hand side of the screen you should see HD44780-V1.0.0.1.  The V1.0.0.1 corresponds to the version of the dll.

Configuration

To get started testing the HD44780 Protocol Analyzer, make sure your Logic/Logic 16 is not connected to your computer.  This will allow you to select a demo Logic/Logic 16 device and run the simulations contained in the code.  From the options menu select Connected Devices/Demo Logic 16.

Figure 5 – Device Selection

On the first channel, select the option to reset everything, this will clear up any custom names you may have on your channels and make all 16 channels visible.  Hide all channels below channel 10, only channels 0-10 are needed.

Figure 6 – Channel Reset

Edit the settings of the analyzer and make sure all data channels look like that of picture 1 and the Data Generation option is set for 8|4 Bit Initialization Sequence.  Save the settings and select the option to rename the channels, this makes the analysis easier.  Select 2 M Samples at 16Mhz and click the Start Simulation button at the top of the screen.  Note the Start Simulation option is only available when the device is not connected.

Figure 7 – Simulation

Zoom in on the first command sent to the HD44780 and you should see the information depicted in figure 8.

Figure 8 – Simulation Results

The name of the function and its parameters are displayed in a bubble on the enable (E) channel.  SetInterface commands sent as part of the first 5 commands are considered initialization commands and marked with the icon with the number 1 in a circle.  The location of the icon indicates the position in the pulse where all the channels are measured.  Table x illustrates the text displayed by the analyzer for the different commands supported by the HD44780.

[table “20” not found /]

In 7 bit mode, the start frame and end frame are properly identified with a green circle and a square red dot.  The text bubble is displayed over both frames.  Changing the measure position in the setting interface moves the frame marking accordingly.  There is also minimalistic error tracking in 7 bit mode to detect if the control lines are different between the transmission of the first and second nibble of data to the HD44780.

Data Export

This version of the analyzer allows exporting the captured data to two different types of reports.  The first report generates a CSV file so you can manipulate the raw data for each captured frame in a spreadsheet.

Figure 10 – Data Export

The second report generates the commands for a sequence diagram that you can plugin at websequencediagrams and generate a graphical representation of the commands.  Figure 11 illustrates a portion of the sequence diagram generated for the message Hello World! in 11 bit mode.

Figure 11 – Sequence Diagram

Testing

I have tested analyzing the HD44780 protocol in 7 and 8 bit modes using the HD44780 Library by SA Development from AVRFreaks forum.  If you are the lucky owner of a Logic 16 and can test an implementation of an LCD driver and provide feedback on the result, it would be greatly appreciated.  I am planning on testing the Arduino LiquidCrystal library as well to validate the code behaves as expected.

Future Release

That’s all for this release.  In a future release I am considering adding an HTML report with some options to replay the captured stream.  There are also opportunities for enhancing the detection of the initialization sequence and reporting when the commands or signal timing is outside of the specs provided by the datasheet.

15 thoughts on “HD44780 Protocol Analyzer

  1. I love this idea – I like to play with LCDs, and having had an appropriate analyzer would have saved me a lot of headaches in the past.

    When I drop the binary in Logic’s Analyzers directory, however, it doesn’t show up in Logic’s list of available analyzers. Any ideas?

  2. Awesome!!
    I have got a Logic 16 and would like to help you testing it, but I have no Windows. I’d realy like to have this for Mac OS X… 🙂

  3. Sorry, I do not have the facility to compile and test for the MAC. According to the Saleae support team, they have plans to setup a solution to do builds of analyzers across multiple environments. Once they do that, I will submit my code to get compiled for Mac and Linux.

    Thanks.

  4. A few things come to mind. Verify you are dropping the DLL in the Analyzers directory. Also this version is 64 bits, if you are running windows 32 bits, the DLL at codeplex will probably not work. If that is the case let me know and I can compile a 32 bit version.

    Thanks.

  5. Congratulations for the HD44780 Protocol Analyzer!

    Is there a way to port it to Mac OS X?

  6. Yes. The SDK distributed by Saleae supports Windows, Linux and MAC. It would be a matter of taking all the files in the source directory and recompiling them under Xcode. I do not have a Mac development environment, but the folks at Saleae are working on a solution that would allow a protocol developer to submit the source code and have it compiled for all supported platforms. The code for this analyzer does not have any win32 specific code that may represent a problem under the Mac. Once the Saleae solution is implemented I will submit the source code to see how it works. In the meantime if you want to take the source and compile it for the Mac, download the Saleae SDK and they have step by step instructions how to create an analyzer under the Mac. Once you have the framework in place, replace all the files with the ones for this project and that should work.

  7. Nope, I’m running Windows 7 64-bit, but it doesn’t seem to load the DLL.

    When I launch Logic, it has started giving me the following error:

    Unable to ‘LoadLibrary’ on dll
    C:\Program Files\Salae LLC/Analyzers/HD4470Analyzer.pdf
    The specified module could not be found

  8. Andrew the path your provided is to a PDF file not to a DLL. C:\Program Files\Salae LLC/Analyzers/HD4470Analyzer.pdf . It is not clear how the DLL got renamed to PDF, but unzip the file from codeplex and make sure it keeps the proper extension. Hope this helps.

  9. Downloaded the SDK and tried building the example analyzer by Saleae as well as this HD44780 analyzer. Neither build went well. 🙁
    I used OSX 10.6.8 Snow Leopard with Xcode 3.2.6 installed. Although I did not use Xcode but the terminal + python script.

  10. I will have access to a Mac this weekend and will have the opportunity to play with this. I will share my findings after the test.

  11. There is a MAC version of the analyzer posted at Codeplex. The source code had to be modified to perform a few c++ syntax cleanups for which Visual Studio is more lenient than Xcode. Next release will fix all this up. For now, feel free to download the binaries from Codeplex. In the next few days I will release the Xcode project as well.

  12. Nice article, I enjoyed reading.

    However, talking of 11/8/7 bit mode is confusing. The controller datasheet refers to 8 or 4 bit mode with respect to the data path width between your MCU and the HD44780 controller. It is obvious that one cannot eavesdrop on 8 bit mode with an 8 channel logic analyzer (and that’s probably why you refer to it as “11 bit mode”).

  13. I struggled with the best way to present this information since the 11/8/7 modes cannot be directly mapped to the 8/4 bit mode documented in the datasheet without reading the post. You are correct, the reason why the 11 bit mode came into existence was to be able to document the different operating modes of the analyzer.

Comments are closed.