2
\$\begingroup\$

I sniffed DB4..7 of an 2*16 LCD using the below circuit : (Atmega32.PORTA1..3 is connected to GND)

enter image description here

As you see above I connected En pin of LCD to INT0 of Atmega32 (That is configured for Falling Edge firing).

In the interrupt routine I wrote this below codes:

interrupt [EXT_INT0] void ext_int0_isr(void)
    {
    printf("%c",'#');
    printf("%02x", PINA);
    }

In the other hand, in my computer I wrote this code :

import serial
ser=serial.Serial('COM3')

while(1):
    if (ser.read(1)=='#'):
        print '#'
        print ser.read(2)
    else:
        print 'Oops'

And when I powered on my circuit, This below output appears in python :

#
00
#
30
#
30
#
80
#
c0
#
10
#
10
#
00
#
11
#
41
#
61
#
00
#
91
#
a1
#
b1
#
b1
#
b1
#
b1
#
b1
#
b1
#
b1
#
b1
#
10
#
10
#
00
#
d1
#
a1
#
00
#
91
#
91
#
91
#
91
#
91
#
91
#
91
#
91
#
00
#
30
#
30
#
80
#
c0
#
10
#
10
#
00
#
11
#
41
#
61
#
01
#
e1
#
a1
#
b1
#
b1
#
b1
#
b1
#
b1
#
b1
#
b1
#
b1
#
10
#
10
#
00
#
d1
#
a1
#
00
#
91
#
91
#
91
#
91
#
91
#
91
#
81
#
81
#
00
#
30
#
30
#
80
#
c0
#
10
#
10
#
00
#
11
#
41
#
61
#
01
#
e1
#
a1
#
b1
#
b1
#
b1
#
b1
#
b1
#
b1
#
b1
#
b1
#
10
#
10
#
00
#
d1
#
a1
#
00
#
91
#
91
#
91
#
91
#
91
#
91
#
71
#
71

Now I want to analyze this output! But I don't have any idea what is the meaning of it. I appreciate if translate some part of it.

\$\endgroup\$
  • 2
    \$\begingroup\$ Note that when you catch a LCD operation, you do a lot of serial printing in the interrupt routine, which takes a very long time. So you're probably seeing a fairly random sequence of nibbles written to the LCD. \$\endgroup\$ – Brian Drummond Dec 28 '14 at 14:57
1
\$\begingroup\$

I started analyzing the data assuming it to be a HD44780 LCD Controller based device and while it starts off with something similar to the initalization sequence to enter 4-bit mode a lot of data thereafter doesn't seem to make a lot of sense. I think Brian Drummond is quite correct in his comment that you'll be seeing a fairly random sequence of nibbles.

It varies a bit by module but I believe most modules can accept data around every 40 uS and at 115,200 bps it'll take 87 uS to send each character. You're sending three characters so potentially data could be arriving over six times faster than you're sending it.

For initially analyzing the data because the frames won't be all that large the ATmega32 should have enough RAM to capture a decent amount of data and then dump it out. The following is untested so treat it as pseudo-code but should give you a general idea, it should just dump the first 1024 bytes received:

#include <stdint.h>
#define BUF_SIZE 1024
uint8_t buf[BUF_SIZE];
uint16_t buf_pos = 0;

interrupt [EXT_INT0] void ext_int0_isr(void)
{
    if (buf_pos < BUF_SIZE)
        buf[buf_pos++] = PINA;
}

void main(void)
{
    uint16_t i;

    // Enable interrupts here and then wait for buffer to fill
    while (buf_pos < BUF_SIZE)
        ;
    // Dump out buffer
    for (i=0; i < BUF_SIZE; i++)
        printf("#%02x", buf[i]);
    // Stop by looping forever
    while (1)
        ;
}
\$\endgroup\$
2
\$\begingroup\$

These kinds of alphanumerical LCD displays have been using the same protocol for decades, so all the controller IC manufacturers make it basically the same way. I'm not sure if you're trying to figure out the protocol to be able to use the LCD or if your question actually is something like how to make a logic analyzer, but in any case it might be easier for you to first understand the data traffic between the microcontroller and the display. After that it's easier to either communicate with the LCD or make the logic analyzer.

  • Pins 1, 2 and 3 are Ground, Logic VCC and Panel Bias Voltage. The Panel Bias voltage depends on the display type and the requirement for proper contrast can be anything from -10 volts to +2 volts. It's actually a negative voltage referenced to VCC.
  • Pin 4 is register select; low to access the control registers, high to read/write data.
  • Pin 5 is Read/xWrite; it's permanently low because the microcontroller only writes to the module, doesn't read.
  • Pin 6 is Enable, an active high clock pulse; typically data is latched on the falling edge.
  • Pins 7 to 14 are a 8-bit data bus. Bit 7 is the most significant bit and the protocol is constructed so that you can select 8 or 4-bit communication with only the bits 7..4 connected. In 4-it mode, all bus transfers are done with two Enable pulses, first for the High nibble (bits 7..4) and the second for the Low nibble (bits 3..0).
  • Pins 15 and 16, if present, are connected to the LCD backlight.

Here's one datasheet for one of the controller ICs you can refer to about the protocol:

https://www.sparkfun.com/datasheets/LCD/st7066.pdf

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.