Output on a LCD

Comprehensive SPLC780D/HD44780 library

Control functions - Entry mode set

void LcdEntryMode(unsigned char increment, unsigned char shift);

It's really important to understand this function, as it may drive you nuts. This control command is all about memory, and for that I suggest you to pay special attention to the functionality. I already have given you a small brief of the functionality on LCD_Init description, so I may repeat a little bit myself but is worth it. The first parameter controls the DDRAM memory location after each write/read operation. This allows you to write in the following memory position (left or right) without having to define the new location to perform the action. The second parameter is DDRAM memory shifting.

The increment parameter can either have the input as ON or OFF. I decided to have these values as parameters instead of left and right to maintain coherency throughout the program. However left/right would be more appropriate to the control defined here. As said before this is all about DDRAM memory location, if you choose ON then after each write/read operation the memory location of the cursor will increment after operating on the current position. For example, if you are in position 0x00 and then you write the value 0x20. The result will be an overwrite in current memory location (0x00) with the new value (0x20) and the new memory location will be 0x01. This memory location coincides with the cursor location. The OFF option will decrement the memory address. Pay special attention when you’re in the boundaries of each line. If you have the decrement option turned on and you’re in memory position 0x00 then the cursor will go off limits and it will not let you write anything in the memory unless you specify to do so, and to do that you need to set the location where to write/read.

right to left write

On the other hand, with the shift parameter you increment or decrement the entire memory shown on the display. This parameter is tightly connected with the parameter increment, because the shift will follow the direction chosen on the first parameter of this function. The functionality itself is somewhat tricky because you may be writing in the display and not seeing it because the display is shifting its memory locations at the same time. With that said, one example is better to explain the logic behind. Imagine again that you’re with the cursor in DDRAM location 0x00 and you have set the display to increment in each write. Then you also have the shift option turned ON and you write something in the memory. You will not see what you’ve written because the entire display is going to shift is displayed memory locations, following the increment of the first function parameter. If you have one 8x1 characters display, the initial memory shown in the display is from 0x00 to 0x07, but after this write operation, the shown memory space is from 0x01 to 0x07, but you’ve written in the memory location 0x00 and therefore not possible to see.

entry mode example

A final example can be seen in the picture above. I've written in the first line "Shift lcd mode.." and in the second line "Shift left" then I located the cursor in the second line, tenth character. I activated the shift option and have written ‘A’, you’ll see that the 'A' automatically have shifted left with all the rest of the characters. I didn´t told you if I was incrementing or decrementing but by now it should be obvious that I’ve have the increment parameter turned ON.

ps thumbnail

LCD Character Module


TAGS

LCD 16x2, SPLC780D, HD44780, LCD library, write to lcd, read from lcd, 4 bit lcd mode, 8 bit lcd mode


SOURCE CODE

SPLC780D Controller.zip