The Down side to working with character LCDs is that they require 7 or more pins to work, when working with PSOC or microcontrollers, some times you could really use some extra pins, a great alternative for these is working with Serial LCD (data or commands are sent through messages instead of bits to each pin)
Here I have built simple example for operating a networked I2C LCD that only requires 2 communication pins SDA, SCL
You actually don't need to wire anything on the Top design, just drag an I2C Master Block and a I2C LCD block.
The I2C Block should be configured as MASTER and the Data rate for the LCD I used couldn't be higher than 60 kbps.
The I2C_LCD configuration need a little extra work this will depend on the LCD model being used for this section you need to have the datasheet for the LCD handy.
Important data for the LCD configuration
Default I2C Address: 80 (50hex).
Powerup delay: 100ms (this will be used on the code)
Since the LCD I am working with has custom commands they need to be configured on the Custom Commands tab and custom format must be selected
On the datasheet you will find something like this.
Then all the commands must be updated, on the table of commands does not require a command input, so on the configuration tab we must uncheck the box "use command pattern for data writing."
#include <device.h>
int main(void)
{
CyGlobalIntEnable;
I2C_Start();
I2C_LCD_Start();
I2C_LCD_SetContrast(50);
CyDelay(1000u);
I2C_LCD_Position(0u, 19u);
I2C_LCD_PrintString("s");
I2C_LCD_Position(0u, 0u);
I2C_LCD_PrintString("a");
I2C_LCD_WriteControl(I2C_LCD_CURSOR_WINK);
I2C_LCD_Position(1u, 0u);
I2C_LCD_PrintString("Cypress PSOC 4");
I2C_LCD_Position(2u, 2u);
I2C_LCD_PrintString("CYPRESS Demo");
I2C_LCD_WriteControl(I2C_LCD_CURSOR_WINK);
I2C_LCD_Position(3u, 10u);
I2C_LCD_PutChar('$');
}
Comments
Please log in or sign up to comment.