We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I have found a bug inside the LCD_4bit.c source file:
void set_cursor (unsigned char column, unsigned char line) {
unsigned char address;
address = (line * 40) + column;
address = 0x80 + (address & 0x7F);
lcd_write_cmd(address); /* Set DDRAM address counter to 0 */
}
--> address = (line * 0x40) + column; // the offset of 40 does not make sense
I am a little bit confused, that it still works with 40 as factor for set_curor(0, 1).
Greetings Oliver
I am a little bit confused...
What about? You mention both 40 and 0x40. Which is it?
I would expect a value of 40. This is because the data sheet for the LCD controller internally maintains a 40 column display, regardless of the physical one actually fitted.
0x40 is the right value. The second line begins at 0xC0 = 0x80 + 0x40 not at 0xA8 = 0x80 + 40.
I'm confused about the fact, that both addresses are working for the coordinates (0,1).
An offset of 40 is definitely wrong, because for HD44780-compatible displays the second line begins at Address 0xC0.
0x40 is the right value.
Yes. After re-examining the datasheet, I would agree with that.
It's a common mistake to take the examples too seriously though.
I really can't, especially when I see this is the same blinky example (just after a call to set_cursor):
for (i = 0; i < 20000000; i++); /* Wait for initial display */
Ouch.