16
2015 Author: Salaideva thirumani Reviewers: Mr.Sathurappan Version: 1.0 Interfacing LCD With FreeSoC2

Interfacing LCD with FreeSoC2

Embed Size (px)

DESCRIPTION

PSoC (Programmable System on a chip) Series of Integrated Circuits from Cypress Semiconductors is based on ARM Cortex M3 microcontroller. The FreeSoC2 is a development platform for the PSoC series of ICs. PSoC brings together features of the programmable devices and microcontroller-type systems on chips into one package. By placing a programmable fabric between the peripherals and the pins, the FreeSoC2 allows any function to be routed to any pin! Moreover, the on-board PSoC includes a number of programmable blocks which allow the user to define arbitrary digital and analog circuits for their specific application.In this application note, we will see how to interface Hitachi (HD44780) LCD with FreeSoC2.3 applications we are going to see in this Application note.• Displaying string.• Displaying LCD character set.• Displaying user defined custom fonts.

Citation preview

  • 2015

    Author: Salaideva thirumani

    Reviewers: Mr.Sathurappan

    Version: 1.0

    Interfacing LCD With

    FreeSoC2

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Introduction:

    PSoC (Programmable System on a chip) Series of Integrated Circuits from Cypress

    Semiconductors is based on ARM Cortex M3 microcontroller. The FreeSoC2 is a development

    platform for the PSoC series of ICs. PSoC brings together features of the programmable

    devices and microcontroller-type systems on chips into one package. By placing a

    programmable fabric between the peripherals and the pins, the FreeSoC2 allows any function

    to be routed to any pin! Moreover, the on-board PSoC includes a number of programmable

    blocks which allow the user to define arbitrary digital and analog circuits for their specific

    application.

    In this application note, we will see how to interface Hitachi (HD44780) LCD with FreeSoC2.

    3 applications we are going to see in this Application note.

    Displaying string.

    Displaying LCD character set.

    Displaying user defined custom fonts.

    There are four parameters available in LCD configuration parameter now we see what the

    functions of each parameter,

    None: When this option is enabled then normal things like printing strings can be

    done. But it doesnt do anything with custom character set.

    Vertical Bargraph: Generate Custom character and API to manipulate the Vertical

    Bargraph.

    Horizontal Bargraph: Generate Custom character and API to manipulate the

    horizontalBargraph.

    User Defined: Creating user custom characterand use API to manipulate them.

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Figure 1 Configuration parameters of CharLCD

    Steps for Displaying String:

    Step 1: Open PSOC creator IDE.

    Figure 2 Open PSoC Creator IDE

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Step 2: Create a new file from File -> New Project & select PSOC5LP design and store with desired name

    Figure 3 Workbench

    Step 3: Select the Character LCD form Component catalog and drag it to the schematic window.

    Figure 4 Drag LCD component

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Step 4: Double click the Character LCD and select None

    Figure 5 LCD setup

    Step 5: Then open the Cydwr file and select the port. Here selected port is P5 (6.0) port.

    Figure 6 Open Schematic

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Step 6: Open main.c file and type the program.

    Figure 7 Open main.c

    Algorithm for printing a string: Step 1: Include header file project.h Step 2: Include main () function. Step 3: Initialize the LCD by Start () function. Step 4: Set the position (row, column) for the message to bedisplayed in LCD. Step 5: Enter the string inside the PrintString () that to be displayed in the LCD. Step 6: Exit the main () function. Program for printing a string:

    #include

    int main()

    {

    LCD_Start();/*Initialize the LCD

    LCD_Position(0u, 3u);/*LCD Position 0th row 4th column. */

    LCD_PrintString("Tenet Tech"); /*String that is to be printed in the LCD*/

    LCD_Position(1u, 0u);/*LCD Position 1st row 0th column. */

    LCD_PrintString("www.tenettech.com");/*String that is to be printed in the

    LCD*/

    }

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Step 7: Connect Micro B cable to the debugger port and then click build -> Generate application.

    Figure 8 Generate Application

    Step 8: Click Debug ->program or Press ctrl+F5

    Figure 9 Program the Board

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Step 9: Connect LCD with FreeSoC2 board.

    Figure 10 Pin Connection

    Figure 11 LCD with FreeSoC2

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Output Image:

    Figure 12 Output Image

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Steps for printing LCD character set:

    To print the LCD character set by means of ASCII in Hexadecimal Value(Refer image 13&14). Follow the same

    steps followed in displaying strings. Thedifference is in the programonly and forget not to enableInclude ASCII

    to Number Conversion Routines.

    Algorithm for printing LCD character set: Step 1: Include header file project.h Step 2: Include main () function. Step 3: Initialize the LCD by Start () function. Step 4: Set the position (row, column) for the message to be displayed in LCD. Step 5: Enter the hexadecimal value for character inside the WriteData () function that to be displayed in the LCD.

    Step 6: Exit the main () function.

    Program:

    #include

    int main()

    {

    LCD_Start(); //initialization of LCD

    LCD_Position(0U,0U); /*first row first column*/

    LCD_WriteData(0x21); /*Hexadecimal code for printing ! */

    LCD_Position(0U,1U); /*first row second column*/

    LCD_WriteData(0x22); /*Hexadecimal code for printing */

    LCD_Position(0U,2U); /*first row third column*/

    LCD_WriteData(0x23); /*Hexadecimal code for printing # */

    LCD_Position(0U,3U); /*first row fourth column*/

    LCD_WriteData(0x24); /*Hexadecimal code for printing $ */

    LCD_Position(0U,4U);

    LCD_WriteData(0x25); /*Hexadecimal code for printing % */

    LCD_Position(0U,5U);

    LCD_WriteData(0x26); /*Hexadecimal code for printing & */

    LCD_Position(0U,6U);

    LCD_WriteData(0x27); /*Hexadecimal code for printing */

    LCD_Position(0U,7U);

    LCD_WriteData(0x28); /*Hexadecimal code for printing ( */

    LCD_Position(0U,8U);

    LCD_WriteData(0x29); /*Hexadecimal code for printing ) */

    LCD_Position(0U,9U);

    LCD_WriteData(0x2A); /*Hexadecimal code for printing * */

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    LCD_Position(0U,10U);

    LCD_WriteData(0x2B); /*Hexadecimal code for printing + */

    LCD_Position(0U,11U);

    LCD_WriteData(0x2C); /*Hexadecimal code for printing , */

    LCD_Position(0U,12U);

    LCD_WriteData(0x2D); /*Hexadecimal code for printing - */

    LCD_Position(0U,13U);

    LCD_WriteData(0x2E); /*Hexadecimal code for printing . */

    LCD_Position(0U,14U);

    LCD_WriteData(0x2F); /*Hexadecimal code for printing / */

    LCD_Position(0U,15U);

    LCD_WriteData(0x30); /*Hexadecimal code for printing 0 */

    LCD_Position(1U,0U);

    LCD_WriteData(0x30); /*Hexadecimal code for printing 0 */

    LCD_Position(1U,1U);

    LCD_WriteData(0x31); /*Hexadecimal code for printing 1 */

    LCD_Position(1U,2U);

    LCD_WriteData(0x32); /*Hexadecimal code for printing 2 */

    LCD_Position(1U,4U);

    LCD_WriteData(0x33); /*Hexadecimal code for printing 3 */

    LCD_Position(1U,5U);

    LCD_WriteData(0x34); /*Hexadecimal code for printing 4 */

    LCD_Position(1U,6U);

    LCD_WriteData(0x35); /*Hexadecimal code for printing 5 */

    LCD_Position(1U,7U);

    LCD_WriteData(0x36); /*Hexadecimal code for printing 6 */

    LCD_Position(1U,8U);

    LCD_WriteData(0x37); /*Hexadecimal code for printing 7 */

    LCD_Position(1U,9U);

    LCD_WriteData(0x38); /*Hexadecimal code for printing 8 */

    LCD_Position(1U,10U);

    LCD_WriteData(0x39); /*Hexadecimal code for printing 9 */

    LCD_Position(1U,11U);

    LCD_WriteData(0x3A); /*Hexadecimal code for printing : */

    LCD_Position(1U,12U);

    LCD_WriteData(0x3B); /*Hexadecimal code for printing ; */

    LCD_Position(1U,13U);

    LCD_WriteData(0x3C); /*Hexadecimal code for printing < */

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    LCD_Position(1U,14U);

    LCD_WriteData(0x3D); /*Hexadecimal code for printing = */

    LCD_Position(1U,15U);

    LCD_WriteData(0x3E); /*Hexadecimal code for printing > */

    LCD_Position(1U,16U);

    LCD_WriteData(0x3F); /*Hexadecimal code for printing ? */

    }

    LCD Character set tabular column:

    Figure 13 Character set

    Supposeif we want to print + sign then binary value would be 00101011 and then convert to hexadecimal

    value - 0x2B .If we want to print + value then in program we have to assign corresponding HEX value.

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Figure 14 Binary to Hexa value

    Output Image:

    Figure 15 Output with 32 characters set.

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Steps for Printing user defined custom set in LCD:

    Enable the User defined in configure LCD dialog box and draw the pattern we want to print in LCD and then

    follow the same steps followed in printing strings experiment, the difference will be in the program and

    configuration of CharLCD.

    Figure 16 Configure User Defined

    Algorithm for printing LCD character set: Step 1: Open the configure LCD dialog box and enable user defined option. Step 2:Draw the custom fonts (Custom 0, 1, 2, 3, 4, 5, 6, 7) by selecting blocks in Custom Character Editor. Step 3: Include header file project.h Step 4:Initialize the custom fonts section by commandextern uint8 constLCD_customFonts [ ]. Step 5:Include main () function. Step 6:Initialize the LCD by Start () function. Step 7:Load custom Fonts by LoadCustomFonts (defined name _customFonts) Step 8:Set the position (row, column) for the message to be displayed in LCD. Step 9: Enter the string that is to be displayed in the LCD by PrintString() function. Step10:Display the custom fonts that is created in the step 2 by using PutChar (defined name_CUSTOM_NO) Step 11:Exit the main () function.

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    Program for printing custom set (*draw the custom font in Configure char LCD): #include

    externuint8constCYCODE LCD_customFonts[]; /*initialization for

    enabling custom font*/

    int main()

    {

    LCD_Start();

    LCD_LoadCustomFonts(LCD_customFonts);

    for(;;) /*infinite loop*/

    {

    LCD_Position(1u,3u); /* set the LCD position in 2nd row 3rd column*/

    LCD_PrintString("Tenet Tech"); /*Input the string we want to print*/

    LCD_Position(0U,0U);

    LCD_PutChar(LCD_CUSTOM_0); /*Print the char which is drawn in the custom

    font 0*/

    LCD_Position(0U,1U);

    LCD_PutChar(LCD_CUSTOM_1); /*Print the char which is drawn in the custom

    font 1*/

    LCD_Position(0U,2U);

    LCD_PutChar(LCD_CUSTOM_2);/*Print the char which is drawn in the custom

    font 2*/

    LCD_Position(1u,3u);/*2nd row 3rd column */

    LCD_PrintString("Tenet Tech");

    }}

    Output image:

    Figure 17 Output Custom Fonts Displayed in the Top Row

  • # 9/3, 2nd floor, SreeLaksmi Complex, opp, to Vivekananda Park, Girinagar, Bangalore - 560085,

    Email: [email protected], Phone: 080 - 26722726

    For product link:

    1. http://www.tenettech.com/product/7241/freesoc2-development-board-psoc5lp

    2. http://www.tenettech.com/product/2442/16-x-2-character-lcd-display-with-backlight-

    jhd162a-green

    3. http://www.tenettech.com/product/2609/basic-breadboard

    4. http://www.tenettech.com/product/2277/jumper-wires-ff-pack-of-10

    For more information please visit: www.tenettech.com

    For technical query please send an e-mail: [email protected]