Infineon-Component - I2C - LCD - V1.10-Software Module Datasheets-V01 - 02-EN
Infineon-Component - I2C - LCD - V1.10-Software Module Datasheets-V01 - 02-EN
Features
Communicate on a 2-wire I2C bus
The API is compatible with the current character LCD component
A single component may drive one or more LCDs on the same
I2C bus
The I2C LCD can coexist on an existing I2C bus if the PSoC is the I2C master
General Description
The I2C LCD component drives an I2C interfaced 2 line by 16 character LCD. The I2C LCD
component is a wrapper around an I2C Master component and makes use of an existing I2C
Master component. If a project does not already have an I2C Master component, one is required
in order to operate. When one of the API functions is called, that function calls one or more of the
I2C Master functions in order to communicate with the LCD.
Input/Output Connections
The component does not have any connection because it is a software component.
Cypress Semiconductor Corporation • 198 Champion Court • San Jose, CA 95134-1709 • 408-943-2600
Document Number: 001-88606 Rev. *B Revised September 6, 2016
Character LCD with I2C Interface (I2C LCD) PSoC® Creator™ Component Datasheet
Component Parameters
Drag an I2C LCD onto your design and double-click it to open the Configure dialog as illustrated
in Error! Reference source not found..
General Tab
The General tab provides options to configure the general settings of the I2C LCD. These
parameters are available.
Vertical Bar Graph – Generate custom characters and API to manipulate a vertical bar
graph.
Horizontal Bar Graph – Generate custom characters and API to manipulate a horizontal
bar graph.
Command format
This parameter has two options. If NXP PCF2119x + custom commands is selected this means
that component uses embedded support of NXP PCF2119x command protocol and also it allows
user to enter any extended (custom) commands that NXP compatible LCD module supports. The
custom commands can be entered in the Custom Commands tab. If you plan to use the LCD
with a command set that is different than the NXP PCF2119x select Custom format. In this
case, you enter the required commands in the Custom Commands tab. You can also enter any
other commands supported by the specific LCD module in the Custom commands table.
Required commands
This group box contains a list of mandatory commands that you must define for component
operation. This table has a command set that is mandatory for NXP PCF2119x compatible LCD
Modules.
# Command Description
1 Write a byte or multiple bytes of data
2 Display on, cursor off
3 Display and cursor off
4 Set cursor position
5 Cursor home
6 Reset cursor position
7 Move cursor left one place
8 Move cursor right one place
9 Underline cursor on
10 Display - on, cursor - off, set cursor wink
11 Display - on, cursor - off, set cursor blink
12 Clear screen
13 Load custom character
14 Set display for 2 lines and 16 characters
15 Move cursor/shift display right (cursor position auto increment)
16 Move cursor/shift display right (cursor position auto decrement)
When NXP PCF2119x + custom commands option is selected, the Required commands
table is grayed out as patterns of required commands are already embedded into the
component. In the case of a Custom format you need to enter proper command patterns for
each required command. If some of commands are not supported by the specific LCD module
you must enter a dummy command pattern.
Set cursor position
For the NXP PCF2119x compatible LCD modules the command codes from 0x80 and above are
used for setting the address of Display Data RAM (DDRAM).For example, the address of 0x80
maps to row 0 and column 0 of the LCD module and the address 0x83 maps to row 0 and
column 3. For detailed information on mapping of DDRAM to LCD location please see the LCD
module datasheet.
Command Size
This parameter specifies the size (in bytes) of command sequence without parameters or actual
data.
Data size
This parameter defines the size of data that is sent after the command sequence for the
specified command.
Command description
This is short descriptions of what the command does. It helps to match command patterns from
the customizer with commands from the LCD Module’s datasheet.
By default, when the Custom commands parameter is selected, the required commands are
filled with command patterns for the NXP PCF2119x command format.
Custom commands
In this section you define custom command handlers for specific commands. You also have a
mechanism to add new commands. The column definitions in this group box are the same as for
Required Commands but there are two additional columns.
Enable
This option, when checked, enables the use of the respective command pattern in the design. It
means that the API function is provided for the command pattern.
API name
This parameter specifies the name of API function that is generated (if enabled) for the
command pattern. The API name specified in this column is appended with a component
instance name at the beginning of the name. Also depending on the data size the API function
will or will not have a parameter. For example, for the API name “Func1” with component
instance name “I2C_LCD” and Data size equal to zero the API function has this prototype:
void I2C_LCD_Func1(void);
Functions
Functions Description
I2C_LCD_Start() Starts the module and loads custom character set to LCD if it was
defined.
I2C_LCD_Stop() Turns off the LCD
I2C_LCD_DisplayOn() Turns on the LCD module’s display
I2C_LCD_DisplayOff() Turns off the LCD module’s display
I2C_LCD_PrintString() Prints a null-terminated string to the screen, character by character
I2C_LCD_PutChar() Sends a single character to the LCD module data register at the current
position.
I2C_LCD_Position() Sets the cursor’s position to match the row and column supplied
I2C_LCD_WriteData() Writes a single byte of data to the LCD module data register
I2C_LCD_WriteControl() Writes a single-byte instruction to the LCD module control register
I2C_LCD_ClearDisplay() Clears the data from the LCD module’s screen
I2C_LCD_Init() Performs initialization required for component’s normal work
I2C_LCD_Enable() Turns on the display
Functions Description
I2C_LCD_SetAddr() This function allows the user to change the default I2C address of the
LCD.
I2C_LCD_PrintInt8() Prints a two-ASCII-character hex representation of the 8-bit value to the
Character LCD module.
I2C_LCD_PrintInt16() Prints a four-ASCII-character hex representation of the 16-bit value to
the Character LCD module.
I2C_LCD_PrintNumber() Prints the decimal value of a 16-bit value as left-justified ASCII
characters
I2C_LCD_HandleOneByteCommand() This command adds a support of sending custom commands with 1
byte parameter
I2C_LCD_HandleCustomCommand() Performs sending of the command that has variable parameters.
These optional functions are included, when needed, if you-select a custom font. The
I2C_LCD_LoadCustomFonts() function comes with every custom font set, whether it is user-
defined or PSoC Creator generated. The I2C_LCD_LoadCustomFonts() function can be used to
load the user-defined or the bar graph characters into the LCD hardware. If you load custom
fonts created by the tool, you need to import a pointer to the custom font to your project before
using this function (see the description of the I2C_LCD_LoadCustomFonts()). By default, the
I2C_LCD_Init() routine loads the user-selected custom font. The draw bar graph commands are
generated when a bar graph is selected and enable the easy, dynamic adjustment of bar graphs.
Optional Custom Font Functions Description
Global Variables
Function Description
I2C_LCD_initVar The I2C_LCD_initVar variable is used to indicate initial configuration of this
component. This variable is prepended with the component name. The variable
is initialized to zero and set to 1 the first time I2C_LCD_Start() is called. This
allows for component initialization without reinitialization in all subsequent calls
to the I2C_LCD_Start() routine.
It is necessary to reinitialize the component when the device is going through
sleep cycles. Therefore, the variable is set to zero when going into sleep
I2C_LCD_Sleep() and set during the reinitialization done in I2C_LCD_Wakeup().
I2C_LCD_customFonts[] Stores custom character set that was defined in the customizer's GUI.
void I2C_LCD_Start(void)
Description: When this function called first time it initializes the LCD hardware module as follows:
It also loads a custom character set to LCD if it was defined in the customizer's GUI.
Resets the cursor to start position.
All of the following call to this function will just turn on the LCD module.
Note This function sends commands to the display using the I2C Master. The I2C Master
must be initialized and global interrupts must be enabled before calling this function.
Also if you are using the NXP-compatible LCD modulenote that it requires a 1 ms reset pulse
prior to calling I2C_LCD_Start(). Refer to the I2C LCD example project to see the proper way
of resetting the LCD module.
Parameters: None
Return Value: None
Side Effects: None
void I2C_LCD_Stop(void)
Description: Turns off the display of the LCD screen but does not stop the I2C Master component.
Parameters: None
Return Value: None
Side Effects: None
Parameters: char8 const string[]: Null-terminated array of ASCII characters to be displayed on the LCD
module’s screen.
Return Value: None
Side Effects: None
Note Because of the character set that is hardcoded to NXP PCF2119x LCD module, which is
used in the PSoC4 processor module, some of characters can’t be displayed. Refer to
Functional Description section for details.
Note Because of the character set that is hardcoded to NXP PCF2119x LCD module, which is
used in the PSoC4 processor module, some of characters can’t be displayed. Refer to
Functional Description section for details.
void I2C_LCD_ClearDisplay(void)
Description: Clears the contents of the screen and resets the cursor location to be row and column zero.
It calls I2C_LCD_WriteControl() with the appropriate argument to activate the display.
Parameters: None
Return Value: None
Side Effects: Cursor position reset to row – 0, column - 0.
void I2C_LCD_DisplayOff(void)
Description: Turns the display off, but does not reset the LCD module in any way. It calls function
I2C_LCD_WriteControl() with the appropriate argument to deactivate the display.
Parameters: None
Return Value: None
Side Effects: None
void I2C_LCD_DisplayOn(void)
Description: Turns the display on, without initializing it. It calls function I2C_LCD_WriteControl() with the
appropriate argument to activate the display.
Parameters: None
Return Value: None
Side Effects: Disables underlining of the cursor if it was previously enabled.
void I2C_LCD_Init(void)
Description: Performs initialization of the LCD module as following:
It also loads a custom character set to LCD if it was defined in the customizer's GUI.
Resets the cursor to start position
Parameters: None
Return Value: None
Side Effects: None
void I2C_LCD_Enable(void)
Description: Turns on the display.
Parameters: None
Return Value: None
Side Effects: None
Macros
To simplify the use of a system that uses multiple LCDs on a single bus, a macro for each API is
added that includes the I2C address of the LCD. For example, the address macro for the
command “I2C_LCD_Position(row, col)” is “I2C_LCD_AddrPosition(addr, row, col)”. The
parameter “addr” is the I2C address of the LCD. Calling the macro function is the same as calling
the I2C_LCD_SetAddr() function before calling the native function. For example, calling the
macro function:
I2C_LCD_AddrPosition(addr, row, col);
This function is exactly like calling these two functions, one after the other:
I2C_LCD_SetAddr(addr);
I2C_LCD_Position(row, col);
As expected, the I2C LCD address remains until another macro is called or the
I2C_LCD_SetAddr() function itself is called. Here is a summary table of the macros that are
supported.
I2C_LCD_Start() I2C_LCD_AddrStart()
I2C_LCD_Stop() I2C_LCD_AddrStop()
I2C_LCD_DisplayOn() I2C_LCD_AddrDisplayOn()
I2C_LCD_DisplayOff() I2C_LCD_AddrDisplayOff()
I2C_LCD_PrintString() I2C_LCD_AddrPrintString()
I2C_LCD_PutChar() I2C_LCD_AddrPutChar()
I2C_LCD_Position() I2C_LCD_AddrPosition()
I2C_LCD_WriteData() I2C_LCD_AddrWriteData()
I2C_LCD_WriteControl() I2C_LCD_AddrWriteControl()
I2C_LCD_ClearDisplay() I2C_LCD_AddrClearDisplay()
I2C_LCD_Init() N/A
I2C_LCD_Enable() I2C_LCD_AddrEnable()
I2C_LCD_LoadCustomFonts() I2C_LCD_AddrLoadCustomFonts()
I2C_LCD_DrawHorizontalBG() I2C_LCD_AddrDrawHorizontalBG()
I2C_LCD_DrawVerticalBG() I2C_LCD_AddrDrawVerticalBG()
I2C_LCD_SetAddr() N/A
I2C_LCD_PrintInt8() I2C_LCD_AddrPrintInt8()
I2C_LCD_PrintInt16() I2C_LCD_AddrPrintInt16()
I2C_LCD_PrintNumber() I2C_LCD_AddrPrintNumber()
I2C_LCD_HandleCustomCommand() I2C_LCD_AddrHandleCustomCommand()
To simplify access to custom commands defined in the component’s GUI, these macros are
generated. The names shown below correspond to “Func1” entered in the API name of Custom
command table.
I2C_LCD_FUNC1 – Defines the command code (the value that is entered in CMD byte 2),
that can be used as a parameter of I2C_LCD_WriteControl(),
I2C_LCD_HandleOneByteCommand() or I2C_LCD_HandleCustomCommand().
MISRA Compliance
This section describes the MISRA-C:2004 compliance and deviations for the component. There
are two types of deviations defined: project deviations – deviations that are applicable for all
PSoC Creator components and specific deviations – deviations that are applicable only for this
component. This section provides information on component specific deviations. The project
deviations are described in the MISRA Compliance section of the System Reference Guide
along with information on the MISRA compliance verification environment.
The I2C LCD component has the following specific deviations:
MISRA- Rule Class
C:2004 (Required/
Rule Advisory) Rule Description Description of Deviation(s)
19.7 R A function shall be used in preference to a A function-like macro is used in the
function-like macro. component to handle differences in the
API function names of the I2C Master
implemented on the UDB and I2C Master
implemented on the SCB.
Also function-like macros are used to
simplify usage of custom commands.
Functional Description
Block Diagram and Configuration
The I2C LCD component is a wrapper around an I2C Master component. The component
provides the library for generating transactions defined by the NXP PCF2119x chip. It also has
support for the generation of custom I2C LCD modules, which are similar to the NXP PCF2119x
command format. With the I2C LCD component it is possible to communicate with several LCDs,
of the same type using address macros. Also, you can use several components to add support
for LCDs with different command formats. All of the I2C components can share the same I2C
Master component.
Customizer Customizer
API API
HW
Implementation
(Verilog or Fixed
Function)
PSoC Device
I2C Bus
for both LCDs are shown in the following figure, and those characters that differ are marked with
red color.
Figure 2. Character Sets for NXP PCF2119x and Hitachi HD44780 LCD Modules
Resources
The I2C LCD component is a software component and uses no hardware resources.
Registers
N/A
I2C_LCD_DisplayOn() - 0.44 - ms
I2C_LCD_DisplayOff() - 1.94 - ms
1The values were received on PSoC3 device with BUS_CLK set to 24 MHz
I2C_LCD_PutChar() - 0.43 - ms
I2C_LCD_Position() - 0.43 - ms
I2C_LCD_WriteData() - 0.43 - ms
I2C_LCD_WriteControl() - 0.49 - ms
I2C_LCD_ClearDisplay() - 1.98 - ms
I2C_LCD_Init() - 14.4 - ms
I2C_LCD_Enable() - 0.44 - ms
I2C_LCD_SetAddr() - 2 - us
I2C_LCD_HandleCustomCommand() - 0.623 - ms
I2C_LCD_HandleOneByteCommand() - 0.62 - ms
I2C_LCD_LoadCustomFonts() - 9.0 - ms
I2C_LCD_DrawHorizontalBG() - 1.944 - ms
I2C_LCD_DrawVerticalBG() - 3.465 - ms
I2C_LCD_PrintInt8() - 0.55 - ms
I2C_LCD_PrintInt16() - 1.1 - ms
I2C_LCD_PrintNumber() - 1.03 - ms
Component Changes
This section lists the major changes in the component from the previous version.
Version Description of Changes Reason for Changes/Impact
1.10.b Minor datasheet edit.
1.10.a Add I2C_LCD_SetAddr () function description The function description was missing.
to Application Programming Interface section.
1.10 Fixed a warning about static function - The warning was appearing when the command format
I2C_LCD_SendCmd(), which was declared option was set to "Custom format".
but not defined, was fixed.
1.0a A note of resetting the NXP-compatible LCD Address an issue with the NXP-compatible LCD
module was added to description of module.
I2C_LCD_Start()
1.0 Version 1.0 is the first release of the I2C LCD
component
© Cypress Semiconductor Corporation, 2013-2016. This document is the property of Cypress Semiconductor Corporation and its subsidiaries, including Spansion LLC (“Cypress”). This
document, including any software or firmware included or referenced in this document (“Software”), is owned by Cypress under the intellectual property laws and treaties of the United States and
other countries worldwide. Cypress reserves all rights under such laws and treaties and does not, except as specifically stated in this paragraph, grant any license under its patents, copyrights,
trademarks, or other intellectual property rights. If the Software is not accompanied by a license agreement and you do not otherwise have a written agreement with Cypress governing the use
of the Software, then Cypress hereby grants you a personal, non-exclusive, nontransferable license (without the right to sublicense) (1) under its copyright rights in the Software (a) for Software
provided in source code form, to modify and reproduce the Software solely for use with Cypress hardware products, only internally within your organization, and (b) to distribute the Software in
binary code form externally to end users (either directly or indirectly through resellers and distributors), solely for use on Cypress hardware product units, and (2) under those claims of Cypress’s
patents that are infringed by the Software (as provided by Cypress, unmodified) to make, use, distribute, and import the Software solely for use with Cypress hardware products. Any other use,
reproduction, modification, translation, or compilation of the Software is prohibited.
TO THE EXTENT PERMITTED BY APPLICABLE LAW, CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS DOCUMENT OR ANY
SOFTWARE OR ACCOMPANYING HARDWARE, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. To the extent permitted by applicable law, Cypress reserves the right to make changes to this document without further notice. Cypress does not assume any liability arising out of
the application or use of any product or circuit described in this document. Any information provided in this document, including any sample design information or programming code, is provided
only for reference purposes. It is the responsibility of the user of this document to properly design, program, and test the functionality and safety of any application made of this information and
any resulting product. Cypress products are not designed, intended, or authorized for use as critical components in systems designed or intended for the operation of weapons, weapons
systems, nuclear installations, life-support devices or systems, other medical devices or systems (including resuscitation equipment and surgical implants), pollution control or hazardous
substances management, or other uses where the failure of the device or system could cause personal injury, death, or property damage (“Unintended Uses”). A critical component is any
component of a device or system whose failure to perform can be reasonably expected to cause the failure of the device or system, or to affect its safety or effectiveness. Cypress is not liable, in
whole or in part, and you shall and hereby do release Cypress from any claim, damage, or other liability arising from or related to all Unintended Uses of Cypress products. You shall indemnify
and hold Cypress harmless from and against all claims, costs, damages, and other liabilities, including claims for personal injury or death, arising from or related to any Unintended Uses of
Cypress products.
Cypress, the Cypress logo, Spansion, the Spansion logo, and combinations thereof, WICED, PSoC, CapSense, EZ-USB, F-RAM, and Traveo are trademarks or registered trademarks of
Cypress in the United States and other countries. For a more complete list of Cypress trademarks, visit cypress.com. Other names and brands may be claimed as property of their respective
owners.