'PIC16 LCD 12864B control

I'm trying to use 12864B 7920 LCD on a PIC16F environment (PIC16F84A). As I'm not so skilled in the microprocessor field, I took a generic 4-bit control program to learn about it. Following that, I built and tested the firmware with XC8,simulating it on Proteus 8.13 (thank you to GITHUB guys that made the 12864B model!) and also on a suitable breadboarded hardware circuit that behaved identically. This learning example uses a 2-rows only display, while the 12864B can display 4 rows by 16 characters each. The commands to the display controller are identical, so I had no problem in reversing on the 12864B. The problems came when I tried to fill with text all the 4 lines: when the first row was filled, the next row to be filled wasn't as it could be logical, the second, but the 4th one. And then, going on, the 2nd and the 3rd. I then looked for the display datasheet, and found a well documented one from Sitronix, that covered the 7920 LCD controller. On this datasheet it's stated that the starting address of each row is hx80, 90, A0, B0. But when I put commands to move the cursor to those addresses, the first two, 80 and 90h behaved as expected, while the others weren't displayed at all. Tampering with the addresses, the best I could do was to also display on the 4th row, but starting at 98h, that instead of partially overwriting the 2nd row, starts on the 1st char of the 4th row. I spent whole days trying to figure if there were some other command to swap the cursor between the rows, also googling a lot, but I only found some Arduino projects that hide details behind Arduino libraries. As a last observation, I can tell that, if I give an address >B0h I overwrite the 1st row. My usual test texts are either "The quick brown fox jumps over the lazy dog 0123456789" partitioned into 16 characters chunks, or 4 strings "x123456789ABCDF" where I change the 1st char with y, z, t. The only way I presently have to correctly display a row is to avoid any cursor control code past the initial 80h and simply send character by character an array of 16 x 4 characters pre-scrambled in the order x,z,y,t 1-16, 33-48, 17-32, 49-64. And this works on either Proteus or hardware. Does anybody know the "magic code" that sends cursor to the requested position on every row? I also add that I tried to modify the delays in the program by a great amount, but even this didn't solve the problem.

At last I got it, so I post here the solution, to save other people wasting time and patience... Here are the true addresses as per the Proteus simulated LCD12864B: line1->0x80,line2->0x90, line3->0xC8,line4->0xD8. I had to put all the lines that way to avoid the editor control takes them as code. Also an hardware test confirms the addresses on the physical display.
That's all.

lcd


Solution 1:[1]

At last I got it, so I post here the solution, to save other people wasting time and patience... Here are the true addresses as per the Proteus simulated LCD12864B: line1->0x80,line2->0x90, line3->0xC8,line4->0xD8. I had to put all the lines that way to avoid the editor control takes them as code. Also an hardware test confirms the addresses on the physical display. That's all.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ArchimedePi