Dot matrix LCD : the CGRAM
Display characters from CGRAM.
We have described the 'operation to write the CGRAM. We have said that to reset the CGRAM is empty and that, however, the fall of the supply voltage determines the loss of the contents of RAM.
So it is essential to load in the cell mask required for the presentation to display the desired character before using it.
BUT this is NOT 'the presentation of the character on the display.
As the characters of CGROM are fixed in memory, but are presented on the display only when their function is called with a writing DDRAM, so by the characters created by user 'CGRAM their appearance on the screen is determined by writing in DDRAM of their code.
Up to here, we are limited to only load a 'programmable area of the GC with new characters and decided that we are not in the ROM. By uploading bytes in CGRAM, basically, we have made potentially available some extra characters, expanding the table CGROM; writing the CGRAM is analogous to having been shopping at the market and filled the fridge. The food will be available to be cooked when I want to (but do not cook for themselves ...).
If we loaded the eight symbols in CGRAM as before, we can view them all with a simple loop.
The program uses a counter initialized to 0 and incremented at each loop to 8. The counter value is used as the data to be sent to DDRAM to display characters in CG from 00h to 07h:
; display 8 symbols from
CGRAM - address 00h to 07h
; display clear and home
from symbol 0
; initialize code counter
movf temp1, w
; move code to W
; write code
; inc code counter
; if bit 3 set = 8
; n - another loop
Obviously I can see only one symbol by sending the corresponding data, between 00h and 07h, exactly as you do with any other symbol defined in the table in CG.
To avoid any confusion should be stressed once again the structure of the character generator RAM:
- 8 blocks of 8 bytes each are available to contain 8 characters in the matrix format 5x8
- the structure of the symbols and the loading of the matrix have been described before
- each block of 8 bytes, corresponding to a symbol, has an access code that corresponds to bytes 00h and 07h of the character table
- when I send in writing to DDRAM a given value between 00h and 07h, I display the corresponding symbol in CGRAM
- There is the possibility of making a mistake loading the symbol in CGRAM: just start from a memory location other than the input of the 8 symbols. For example, if the point relative address of CGRAM 04h and 00h and then not to write eight consecutive bytes, these will be positioned straddling the two symbols called respectively given by 00h and 01h, giving rise to garbled
- However, there is no way to retrieve a symbol "wrong" because, for example by sending the data in DDRAM 05h, the symbol is taken from the CGRAM, with 8 consecutive bytes that have been loaded into CGRAM relative addresses from 20h and 27h.