Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Using 16x4 LCD with PSoC1

Using 16x4 LCD with PSoC1

Anonymous
Not applicable
Question: When data is printed on a 16x4 LCD, data gets shifted by 4 columns on Row2 and Row3. What is the reason for this anomaly and what is the work around?

 

Answer:

The LCD user module is developed for a 20x4 LCD display based on the Hitachi HD44780 driver. 

There is difference in DDRAM addresses for 16x4 and 20x4 displays. The base addresses for the characters for the 4 rows in a 20x4 display are 0, 64, 20, 84.  The base addresses for the characters for the 4 rows in a 16x4 display are 0, 64, 16, 80.

As PSoC uses the address set 0, 64, 20, 84, the characters are displayed at an offset of 4 for Rows 2 and 3.  To get the 16x4 LCD to work fine with the LCD user module, the base addresses for Rows 2 and 3 should be made as 16 and 80.  There are two options to do this.

Option-1: When calling the LCD_Position function, for the column count pass a value (Column - 4).  For example if you want to print a character on Row2, Column0, use LCD_Position (2, -4) instead of LCD_Position (2,0).  This is the preferred method.

Option-2: Another fix which I can tell you is to change LCD.asm file(I have not tested it though). Search for lines

LCD_ROW3_OFFSET: equ 94h
LCD_ROW4_OFFSET: equ D4h

Change them to

LCD_ROW3_OFFSET: equ 90h
LCD_ROW4_OFFSET: equ D0h

Build the project. However, these changes will be lost when the project is regenerated.  If you would like to use this change in all your projects, then you can modify the template file for the LCD user module.

To make changes in template file, go to path:

C:\Program Files\Cypress\Common\CypressSemiDeviceEditor\Data\Stdum\LCD

Make the above modifications in the LCD.asm file. 
After updating the template file, regenerate the code in the PSoC project and the changes made in the template file will reflect in the LCD user module files.  Also, any other project that uses LCD will have the same code.

Warning: It is not adviceable to make any changes to the User module template files.  Do it at your own risk.  Before modifying the files, take a backup of the file so that you can restore it if there is any problem.

0 Likes
494 Views
Contributors