L30 Character Based LCD - Character Based Liquid Crystal...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Character Based Liquid Crystal Displays ECET 209 – Lecture 30 Introduction to Microcontrollers Liquid Crystal Displays • Display ASCII characters – Can also display “special” symbols • Require information to be written – Write data – Write control commands • Allow data to be read ECET 209 Purdue University 2 Serial LCD’s Serial LCD’s VCC VCC 14 13 12 11 10 9 8 7 Asynchronous Serial Synchronous Serial Microcontroller 2 3 VCC VO DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 1 VSS Character LCD Line1 Character LCD Line2 6 A K E R/W RS 5 4 VCC Two-wire Interface ECET 209 Purdue University 3 Serial LCD Daughterboard Images are from Sparkfun.com ECET 209 Purdue University 4 LCD Connections ECET 209 Purdue University 5 LCD Connections ECET 209 Purdue University 6 LCD Connections ECET 209 Purdue University 7 Character LCD’s • Must write both data and control words to LCD’s • Commands: – – – – Clear the display Position the cursor Turn the cursor on or off Control the style of cursor (line or block) ECET 209 Purdue University 8 Character LCD’s • Must write both data and control words to LCD’s • Data: – Strings of ASCII text – Numbers (also in ASCII) ECET 209 Purdue University 9 LCD Functions • Need two basic functions for LCDs – Write Data => putchar_lcd • void putchar_lcd(unsigned char); – Write Commands => putcmd_lcd • void putcmd_lcd(unsigned char); – Create these functions from the solution steps ECET 209 Purdue University 10 Timing Diagram (command) ECET 209 Purdue University 11 Timing Diagram (data) ECET 209 Purdue University 12 Timing Requirements Parameter Enable Cycle Time Enable Pulse Width (high) Enable Rise/Fall Time Address Setup Time Address hold Time Data Setup Time Data Hold Time ECET 209 Symbol tc tw tr,tf tas tah tds th Min 500 230 40 10 80 10 Purdue University Typ - Max 20 - Unit ns ns ns ns ns ns ns 13 Initialization Flowchart ECET 209 Purdue University 14 Initialization Flowchart ECET 209 Purdue University 15 Additional LCD Instructions ECET 209 Purdue University 16 LCD Instructions – Cursor Location Instruction Set DD RAM Address ECET 209 Code RS R/W DB7 0 0 1 DB6 DB5 DB4 DB3 DB2 DB1 DD Adress Purdue University DB0 Description Set the DD RAM Address (position the cursor) 17 LCD Instructions – Cursor Location ECET 209 Purdue University 18 LCD Instructions – Cursor Location Character LCD Line1 Character LCD Line2 Character LCD Line3 Character LCD Line4 Address of the first character is 8410 Address of the first character is 2010 Address of the first character is 6410 Address of the first character is 010 ECET 209 Purdue University 19 ECET 209 Purdue University 20 The putstring_lcd function • Printf works with the serial port…We need a similar function for the LCD • Create putstring_lcd to send a string of characters to the LCD • To accomplish this, we need pointers!! ECET 209 Purdue University 21 putstring_lcd unsigned char *str = "Hello World"; unsigned char ch; while ( *str != 0 ) // if the value is not the NULL terminator { ch = *str; // get the character putchar_lcd( ch ); // send the value str++; // index to the next character } ECET 209 Purdue University 22 putstring_lcd function void putstring_lcd(unsigned char *str) { unsigned char ch; while ( *str != 0 ) // loop until end of text { ch = *str; // get the character putchar_lcd( ch ); // send the value str++; // index to the next character } } ECET 209 Purdue University 23 putstring_lcd function • Declare a string stored in RAM unsigned char *str = “Hello World”; • Call the function with the string putstring_lcd(unsigned char str); • Also works with arrays of ASCII data unsigned char data_array[5] = {0x30,0x31,0x32,0x33,0}; putstring_lcd(data_array); ECET 209 Purdue University 24 Atmel Specific Usage • What about this: putstring_lcd(“Hello World”); ECET 209 Purdue University 25 Atmel Specific Usage • What about this: putstring_lcd(“Hello World”); • Since “Hello World” is stored in Flash, our function must reflect this… void putstringf_lcd(unsigned char flash *); ECET 209 Purdue University 26 Atmel Specific Usage void putstringf_lcd(unsigned char flash *f_str) { unsigned char ch; while ( *f_str != 0 ) // loop until end of text { ch = *f_str; // get the character putchar_lcd( ch ); // send the value f_str++; // index to the next character } } ECET 209 Purdue University 27 ...
View Full Document

This note was uploaded on 02/22/2012 for the course ECET 209 taught by Professor Richardson during the Fall '08 term at Purdue University-West Lafayette.

Ask a homework question - tutors are online