1.3.
Bar Graph Display on LCD
1.3.1. System-Level Diagram
Reset Brightness
PSoC
LCD IP Core
CPU
Figure 22: System Diagram for LCD Interfacing 1.3.2. Background It is possible to draw either a horizontal or a vertical bar graph in the 2X16 LCD modules. Each of the grids is 8 pixels high and 5 pixels wide. Each of these can be used as a unit measure for the graph. Since, it is possible to graph up to 80 units on the horizontal and only 16 units on the vertical the data need to be scaled accordingly.
Col 0 Col 15
Row 0
Row 1
8 Pixels High
Figure 23: Grid size of 2X16 LCD Module
35
5 Pixels Wide
1.3.3.
Equipment Resources Required PSoC Designer 5.0 Software PSoC Mini Programmer USB Cable CY3210-PSoC Evaluation and CY3210-MiniEvaluation board
1.3.4.
Creating a Project Open PSoC Designer 5.0 Software File New Project Project Type (Select Chip Level Project) Give your Project Name Specify your Project Location Ok Select the Target Device (CY8C29466-24PVXI) Generate main file ( Choose any one C/Assembler) Placing User Modules
1.3.5.
Figure 24: Select LCD User Module
36
1.3.6.
Setting PSoC Global Parameters
Figure 25: Global Resources for Chapter 1 1.3.7. Setting User Module Parameters
Figure 26: Set the LCD Port to Port_2 1.3.8. Defining PSoC Pin-Out In this lab, there is no need to select the Pin Out for the user modules as the PSOC designer selects Port_2_0 to Port_2_6 based on our LCDPort selection on the Properties dialog box.
37
Figure 27: Port selection for LCD module
Figure 28: Pin out View
38
1.3.9.
Coding
//---------------------------------------------------------------------------// C main line //---------------------------------------------------------------------------#include <m8c.h> // part specific constants and macros #include "PSoCAPI.h" // PSoC API definitions for all User Modules
void main(void) { LCD_1_Start(); LCD_1_InitVBG(); LCD_1_Position(0,0); LCD_1_DrawVBG(1,1,2,15); LCD_1_DrawVBG(1,3,2,12); LCD_1_DrawVBG(1,5,2,3); LCD_1_DrawVBG(1,7,2,6); LCD_1_DrawVBG(1,9,2,10); LCD_1_DrawVBG(1,11,2,16); } 1.3.10. Programming PSoC module Save the file Generate configure file Compile main project Build the project
39
Figure 29: Building a Project Program->Program Part Select MiniProg1. Set the Acquire Mode on power cycle if external power is not supplied and vice versa.
Figure 30: Program Part Settings 1.3.11. Demonstrate Working Configuration Use Toggle Power or external power to run the design on the PSoC board. Suggested Modification
1.3.12.
40