//------------------------------------------------------------------------------------ // LCD Module //------------------------------------------------------------------------------------ #include #include #include #include "MainHeader.h" #define LCD_E_PIN 0x08 #define LCR_RW_PIN 0x10 #define LCD_RS_PIN 0x20 typedef unsigned char uint8; void LCD_Goto_XY ( unsigned char x, unsigned char y) { unsigned char row_start_address [] = {0x80 , 0xC0 }; // Move cursor to (x,y) location on display LCD_Send_Command ( row_start_address [y -1] + x - 1); Delay (170) ; // Delay for approx . 1.6 ms } void GPIO_Port_Init (void) { // Clock Gating Control SYSCTL_RCGCGPIO_R |= 0x12 ; // enable clock for Port // GPIO configuration for Port B Delay(100); GPIO_PORTB_DIR_R |= 0xFF ; // Port B as output GPIO_PORTB_DEN_R |= 0xFF ; // digital enable GPIO_PORTB_AFSEL_R &= ~0xFF; // regular port function // GPIO Configuration for Port E pins 3, 4 and 5 GPIO_PORTE_DIR_R |= 0x38 ; // Port E pins as output GPIO_PORTE_DEN_R |= 0x38 ; // digital enable GPIO_PORTE_AFSEL_R &= ~0x38; // regular port function // GPIO_Init(); LCD_Init(); LCD_Clear(); } /* This function writes user command to the LCD module . */ void LCD_Send_Command (unsigned char command ) { LCD_DATA_BUS = command ; LCD_CONTROL_BUS = 0; // Generate a pulse on the LCD Enable pin Delay (1) ; LCD_CONTROL_BUS |= LCD_E_PIN ; Delay (1) ; LCD_CONTROL_BUS &= ~( LCD_E_PIN ); Delay (4) ; } /* This function writes user data to the LCD module . */ void LCD_Send_Data (unsigned char data ) { LCD_DATA_BUS = data ; LCD_CONTROL_BUS = LCD_RS_PIN ; // Generate a pulse on the LCD Enable pin Delay (1) ; LCD_CONTROL_BUS |= LCD_E_PIN ; Delay (1) ; LCD_CONTROL_BUS &= ~( LCD_E_PIN ); Delay (4) ; } /* This function initializes the LCD module for 8- bit data interface , turns ON the display and cursor . */ void LCD_Init ( void ) { LCD_CONTROL_BUS = 0; Delay (1500) ; // Wait for approx . 15 ms // Configure LCD for required functionality LCD_Send_Command (0x38); // Function Set : 8 bit , 2 line LCD_Send_Command (0x10); // Set cursor LCD_Send_Command (0x0E); // Display ON , cursor ON LCD_Send_Command (0x06); // Entry mode } /* This function clears LCD module and brings cursor to home position on the display . */ void LCD_Clear ( void ) { LCD_Send_Command (0x01); // Clear display Delay (170) ; // Delay for approx . 1.6 ms LCD_Send_Command (0x02); // Move cursor to home Delay (170) ; // Delay for approx . 1.6 ms } /* This function writes character string to LCD display . */ void LCD_Send_String ( char * ptr ){ while (* ptr ){ LCD_Send_Data (* ptr ); ptr ++; } } void LCD_Send_Float(float f) { unsigned int v,p; long int num; num=f*10000; p=num%10000; v=num/10000; LCD_Send_Integer(v); LCD_Send_String("."); LCD_Send_Integer(p); } void LCD_Send_Integer(int number){// This function prints integer on LCD char buffer[10]; Delay(10); sprintf(buffer,"%d",number); // function sprintf converts integer to string LCD_Send_String(buffer); } /* This function moves the cursor to (x,y) coordinates on the LCD display . */ /* This function generates the delay . */ void Delay ( volatile unsigned int delay ) { volatile unsigned int i, j; for (i = 0; i < delay ; i++) // introduces a delay of about 10 us at 16 MHz { for (j = 0; j < 12; j ++) ; } } void Welcome_Screen(void) { LCD_Send_String("Welcome To"); LCD_Goto_XY(1,2); LCD_Send_String("LCR Meter"); Delay(100000); LCD_Clear(); LCD_Send_String("Group"); LCD_Goto_XY(1,2); LCD_Send_String("Members"); Delay(100000); LCD_Clear(); LCD_Send_String("2016-EE-114"); LCD_Goto_XY(1,2); LCD_Send_String("2016-EE-111"); Delay(100900); LCD_Clear(); LCD_Send_String("2016-EE-108"); LCD_Goto_XY(1,2); LCD_Send_String("2016-EE-107"); Delay(100900); LCD_Clear(); LCD_Send_String("Supervised By"); LCD_Goto_XY(1,2); LCD_Send_String("Ali Shafique"); Delay(100900); LCD_Clear(); }