Shop OBEX P1 Docs P2 Docs Learn Events
Question about Stampworks experiment 13 and Hitachi 2x16 LCD data sheet — Parallax Forums

Question about Stampworks experiment 13 and Hitachi 2x16 LCD data sheet

almost_humanalmost_human Posts: 7
edited 2008-01-22 06:01 in BASIC Stamp
Hi,
Experiments 11 through 13 involve programming the 2x16 Hitachi LCD. I read the code for those experiments and after I understood the code everything made sense. The code shows a particular way to read/write to/from data/custom character RAM of the LCD. The way to do that is to pulse the enable line of the LCD with the Basic Stamp. For example: to send a character to the display RAM, you would set the data bus then pulse the enable line for a few micro secs and to read from the cg RAM, you would pull the enable line high, set the data bus then pull enable low. The one question I have about this whole process is why this information isn't given in the data sheet of the LCD. I looked over the data sheet from beginning to end several times but no where in it does it say to pulse the enable line a certain way for read and a certain way for write.
If I had to do this for a living, I would be given the data sheet for the LCD and told to program it and without the luxury of having example code, how would I know to how to manipulate the enable line to get it to work?
I'm learning the Basic Stamp as a hobby right now but in the future I'm hoping to work as a programmer of some sort. This is my first exposure to reading data sheet, I'm hoping that someone with experience with data sheets would be able to explain this to me, thanks in advance.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-01-16 17:19
    AH,

    I’m not sure what datasheet you’re referring to, but assuming it is ours that information is covered. Most of the examples show an 8-bit data bus, however the Stamp Works example is using 4-bit mode. Nonetheless, the procedure is actually to setup the necessary lines before strobing the enable line. In 4-bit mode this has to be done in two consecutive transactions to get all 8 bits (4-bits at a time).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • almost_humanalmost_human Posts: 7
    edited 2008-01-17 05:02
    Chris Savage said...
    Nonetheless, the procedure is actually to setup the necessary lines before strobing the enable line
    Yea, that's the procedure for writing to RAM but the·procedure to read from RAM is actually different but by just reading the data sheet, you wouldn't know that.

    And the only clue we have on how to strobe the enable line for read and write is figure 9 on page 189 of the LCD data sheet located here: http://www.parallax.com/Portals/0/Downloads/docs/prod/audiovis/Hit44780.pdf.

    I'm·staring at it as we speak and for the life of me I can't figure out how we're expected to know the procedure to strobe the enable line from this diagram. Can anyone tell me what i'm missing?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-01-17 22:39
    Okay, first, on page 9 of the PDF. The signal description for the enable line says, "Starts Data Read/Write". Since the line has no bar over it or slash in front of it we know it to be acive high. Next is, to me, the most important piece of information when working with a device like this...the timing diagram. Notice the transistions of E in relation to data being written? This clearly describes the timing of the Enable line in relation to all other transactions, which by the way easily break down into reads or writes and deal with either the data register or the instruction register. Again, these are defined by the levels on the R/W pin and the RS pin. Table 6 on page 26 of the PDF outlines the reads and writes for DDRAM and CGRAM. Finally, page 50 of the PDF covers the timing of the enable line and other lines.· I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • almost_humanalmost_human Posts: 7
    edited 2008-01-19 05:15
    okay, here's the code to write(LCD_Out) and read(LCD_In) to RAM in experiment #13:

    LCD_Out:
    LcdBusOut = char.HIGHNIB                ' output high nibble
    PULSOUT E, 3                            ' strobe the Enable line
    LcdBusOut = char.LOWNIB                 ' output low nibble
    PULSOUT E, 3
    HIGH RS                                 ' return to character mode
    RETURN
     
    LCD_In:
    HIGH RS                                 ' data command
    HIGH RW                                 ' read
    LcdDirs = %0000                         ' make data lines inputs
    HIGH E
    char.HIGHNIB = LcdBusIn                 ' get high nibble
    LOW E
    HIGH E
    char.LOWNIB = LcdBusIn                   ' get low nibble
    LOW E
    LcdDirs = %1111                          ' make buss lines outputs
    LOW RW                                   ' return to write mode
    RETURN
    


    If you look closely at the code you'll find that to write to RAM you would need to set data bus then strobe E line. To read from RAM, you would need to pull E high set data bus then pull E low. My question is: which diagram on what page in the data sheet tells me to do that?

    I'm looking at the bus timing characteristics table for read/write operations on page 53 and figures 27 & 28 on page 59 but I still don't see how the procedure to strobe E can be derived from that info. The link to the pdf for Stampworks: http://www.parallax.com/Portals/0/Downloads/docs/books/sw/Web-SW-v2.1.pdf

    If I had to do this on my own, looking at the figures on page 59, I would probably use the pulse command on E for both read and write. You know what I'm saying?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-01-20 07:37
    I can see where you might find that code confusing. Why the author of that code chose to handle the E line like that I am unsure about. What I can hypothesize from it is that the LCD samples the data bus on the falling edge of the E transition. So as long as the data is on the bus when E goes low it probably works. Nonetheless had I written the code I would have used a PULSOUT following an OUTx command. There are many ways this could have been done. In fact all lines could have been handled with OUTx statements. This scheme is used to control an LCD Display using a 74HC595 shift register. You could also look into other examples of parallel LCDs being used with the BS2. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Dennis FerronDennis Ferron Posts: 480
    edited 2008-01-20 17:36
    Well hang on now. There might be a good reason the code looks different from the datasheet timing: The author might have figured out to do the code that way by trial and error. Now, that could have been because he was using the chip wrong or had an unrelated problem that went away when he changed the timing, but it could be a real chip glitch. I've run into a similar situation with many older chips like the 8255, ADC8809, and the 6502. All of them have peculiarities which cause them to lock up in certain situations, and the datasheet neglects to mention the caveats. For instance, the 6502 datasheets describe the "Rdy" line as pausing the processor if you assert it after a Sync occurs; what they don't tell you is that you have to assert it only during a particular phase of the clock. If you assert it half a microsecond (1 MHz clock) too soon or too late, the processor never recovers. The 8255 requires that you set the r/w and enable lines a certain way during a reset, and changing the mode of one port clears the data on the other port - both things IIRC I did not find in the datasheet. The ADC8809 requires a clock to do analog to digital conversions. The datasheet does not mention that the clock has to be continuously run. As a microcontroller programmer, I assumed I would just clock the ADC when I needed a conversion, and stop the clock and do other things until I needed another conversion. But when you come back and restart the clock, it doesn't work! This is because the chip was designed to be put on 8 bit microprocessor buses, where the clock runs all the time, and the author of the datasheet never dreamed someone would try to use it the way I did. That was a case where it was my fault for using the chip wrong, but nowhere in the datasheet does it say that you can't use it that way.
  • almost_humanalmost_human Posts: 7
    edited 2008-01-22 06:01
    Thanks for sharing that with us. At least now I know·I'm·not the only one having that problem. If this is the case, then I can't rely on just the datasheet for info.
Sign In or Register to comment.