Tutorials - Elettronica


Dot matrix LCD : the CGRAM

A note.

As said, some uncertainty may arise between the DDRAM addresses, the contents of DDRAM and symbols displayed on the LCD panel.

The controller allows two separate transactions to write to DDRAM:

  • write a DDRAM adrress

  • write a data to DDRAM

The two things are different and have different functions.

When writing an address in DDRAM, we force the internal counter to move to the cell in which you want to access DDRAM. After the reset due to 'arrival of the voltage, the address counter is at 0 and then to the tip of the DDRAM location 0, which corresponds to the first matrix of the display, the home position.
If, at this point, write a given towards the DDRAM, the corresponding character is positioned in the cell to 'address 0.
An automatic mechanism of the controller will advance the counter by one step after each write operation directed to the DDRAM: a further writing position the number given to the cell 1 and the character will be displayed below the first. And so on.

This makes it possible to display a string of characters below, without the need to command a new address in RAM, which is incremented automatically by the counter.

For a code example, starting from 'address 00h, the first character will be sent to this location, the next one does not require any manipulation of' address, as it will be automatically placed at 01h and 02h after and so on.

movlw   0x00           ; indirizzo DDRAM 00h  
call    setddramaddr   ; invio il comando al modulo
movlw   'H'            ; carattere ASCII H  
call    writechar      ; scrivo il carattere sul display
movlw   'i'            ; carattere ASCII i
call    writechar      ; scrivo il carattere sul display 

will display the message  'Hi'  starting from the home location.

However, it may be necessary to display a character in a certain location on the LCD panel. This position corresponds to a certain cell of DDRAM. So, writing that cell, the display will show the desired character in the given position.

To do this I have to force the counter from the current position to the destination, with a write operation to address DDRAM.

Thus, for example, if the 'address where the meter is 00h, the character will be sent to that location and the internal counter will be placed on 01h waiting for the next character. 

If, however, I want to make this automatic, but writing the character at position 5 of the second line of the display, simply send a command set of 'DDRAM address of a value of 5, and then write the data to be submitted. So you can enter or edit characters in any position on the LCD panel.

From the point of view of the code:

movlw   0x00           ; DDRAM address 0  
call    setddramaddr   ; send commnd to the module
movlw   'H'            ; character ASCII H  
call    writechar      ; write the character to the DDRAM
movlw   0x05           ; DDRAM address 5 
call    setddramaddr   ; send commnd to the module
movlw   'i'            ; character ASCII i
call    writechar      ; swrite the character to the DDRAM 

will display the message  'H    i'  starting from the home location.

It should now be clear that the function has the writing of an address or of a data element in DDRAM.

As for the relationship between the DDRAM locations and those displayed on the LCD panel, the sheet form data indicates that information.



Copyright afg. Tutti i diritti riservati.
Aggiornato il 05/12/12.