Chapter 10 Glass Bliss - PowerPoint PPT Presentation

About This Presentation
Title:

Chapter 10 Glass Bliss

Description:

Chapter 10 Glass Bliss Using the ... display shift 1 = Display shift D 0 = Display off 1 = Display on C 0 = Cursor off 1 = Cursor on B 0 = Cursor blink off 1 ... – PowerPoint PPT presentation

Number of Views:58
Avg rating:3.0/5.0
Slides: 18
Provided by: Luci120
Category:
Tags: blink | bliss | chapter | glass

less

Transcript and Presenter's Notes

Title: Chapter 10 Glass Bliss


1
Chapter 10 Glass Bliss
  • Using the Parallel Master Port to communicate
    with Alphanumeric LCD displays

2
Alphanumeric LCD Modules
3
HD44780 Instruction Set
Instruction Code Description /
Execution time RS R/W DB7 DB6 DB5 DB4 DB3 DB2 D
B1 DB0 Clear display 0 0 0 0 0 0 0 0 0 1 Clears
display and returns cursor to the
home position (address 0). 1.64mS Curs
or home 0 0 0 0 0 0 0 0 1 Returns cursor to
home position (address 0). Also
returns display being shifted to the original
position. DDRAM contents remains
unchanged. 1.64mS Entry mode
set 0 0 0 0 0 0 0 1 I/D S Sets cursor move
direction (I/D), specifies to shift
the display (S). These operations
are performed during data
read/write. 40uS Display On/Off
0 0 0 0 0 0 1 D C B Sets On/Off of all display
(D), cursor On/Off (C) and blink of
cursor position character (B). 40uS
Cursor/display shift 0 0 0 0 0 1 S/C R/L Sets
cursor-move or display-shift (S/C), shift
direction (R/L). DDRAM contents
remains unchanged. 40uS Function
set 0 0 0 0 1 DL N F Sets interface data
length (DL), number of display line
(N) and character font(F). 40uS Set CGRAM
addr 0 0 0 1 CGRAM address Sets the CGRAM
address. CGRAM data is sent and
received after this setting. 40uS Set DDRAM
addr 0 0 1 DDRAM address Sets the DDRAM
address. DDRAM data is sent and
received after this setting. 40uS Read busy-flag
and address ctr 0 1 BF CGRAM / DDRAM
address Reads Busy-flag (BF) indicating
internal operation is being
performed and reads CGRAM or DDRAM
address counter contents (depending
on previous instruction). 0uS Write
to CGRAM 1 0 write data Writes data to
CGRAM or DDRAM. 40uS (or DDRAM) Read CGRAM
1 1 read data Reads data from CGRAM or
DDRAM. 40uS (or DDRAM)
4
HD44780 Instruction Set (cont.)
Bit name Setting / Status I/D 0 Decrement
cursor position 1 Increment cursor
position S 0 No display shift 1 Display
shift D 0 Display off 1 Display on C 0
Cursor off 1 Cursor on B 0 Cursor blink
off 1 Cursor blink on S/C 0 Move cursor 1
Shift display R/L 0 Shift left 1 Shift
right DL 0 4-bit interface 1 8-bit
interface N 0 1/8 or 1/11 Duty (1 line) 1
1/16 Duty (2 lines) F 0 5x7 dots 1 5x10
dots BF 0 Can accept instruction 1
Internal operation in progress
5
Character Generator Table
6
Parallel Master Port
7
PMCON
PMCON Register 20-1 (DS61143)
8
LCD Initialization
define LCDDATA 1 // RS 1 access
data register define LCDCMD 0 // RS
0 access command register define PMDATA
PMDIN1 // PMP data buffer void LCDinit(
void) // PMP initialization PMCON
0x83BF // Enable the PMP, long waits
PMMODE 0x3FF // Master Mode 1
PMPEN 0x0001 // PMA0 enabled  
PMADDR LCDCMD // command register
(ADDR 0) PMDATA 0x38 // set
8-bit interface, 2 lines, 5x7 TMR1 0
while( TMR1lt8) // 8 x 6us 48us PMDATA
0x0c // ON, no cursor, no blink
TMR1 0 while( TMR1lt8) // 8 x 6us 48us
PMDATA 0x01 // clear display
TMR1 0 while( TMR1lt300) // 300 x 6us 1.8ms
PMDATA 0x06 // increment
cursor, no shift TMR1 0 while( TMR1lt300)
// 300 x 6us 1.8ms // LCDinit
9
Reading the LCD
char readLCD( int addr) int dummy
while( PMMODEbits.BUSY) // wait for PMP to be
available PMADDR addr //
select the command address dummy PMDATA
// init read cycle, dummy read
while( PMMODEbits.BUSY) // wait for PMP to be
available return( PMDATA) // read
the status register // readLCD define
busyLCD() readLCD( LCDCMD) 0x80 define
addrLCD() readLCD( LCDCMD) 0x7F define
getLCD() readLCD( LCDDATA)
10
Writing to the LCD
void writeLCD( int addr, char c) while(
busyLCD()) while( PMMODEbits.BUSY) //
wait for PMP to be available PMADDR addr
PMDATA c // writeLCD define busyLCD()
readLCD( LCDCMD) 0x80 define addrLCD()
readLCD( LCDCMD) 0x7F define getLCD()
readLCD( LCDDATA)
11
Extending the Include Search Path
12
LCD Control Using the peripheral library
void initLCD( void) // PMP initialization
mPMPOpen( PMP_ON PMP_READ_WRITE_EN 3,
PMP_DATA_BUS_8 PMP_MODE_MASTER1
PMP_WAIT_BEG_4 PMP_WAIT_MID_15
PMP_WAIT_END_4, 0x0001,
// only PMA0 enabled
PMP_INT_OFF) // no interrupts used
// wait for gt30ms Delayms( 30)
//initiate the HD44780 display 8-bit init
sequence PMPSetAddress( LCDCMD) //
select command register PMPMasterWrite(
0x38) // 8-bit int, 2 lines, 5x7
Delayms( 1) // gt 48 us
PMPMasterWrite( 0x0c) // ON, no cursor, no
blink Delayms( 1) // gt 48 us
PMPMasterWrite( 0x01) // clear
display Delayms( 2) // gt
1.6ms PMPMasterWrite( 0x06) //
increment cursor, no shift Delayms( 2)
// gt 1.6ms // initLCD
13
LCD Control Using the peripheral library
char readLCD( int addr) PMPSetAddress(
addr) // select register
mPMPMasterReadByte() // initiate read
sequence return mPMPMasterReadByte()// read
actual data // readLCD     void writeLCD( int
addr, char c) while( busyLCD())
PMPSetAddress( addr) // select register
PMPMasterWrite( c) // initiate write
sequence // writeLCD
14
putsLCD()
void putsLCD( char s) char c
while( s) switch (s)
case '\n' // point to second
line setLCDC( 0x40)
break case '\r' // home, point
to first line setLCDC( 0)
break case '\t' // advance
next tab (8) positions c
addrLCD() while( c 7)
putLCD( ' ')
c if ( c gt 15) //
if necessary move to second line
setLCDC( 0x40) break
default // print character
putLCD( s) break
//switch s //while
//putsLCD
15
Advanced LCD Control
define setLCDG( a) writeLCD( LCDCMD, (a 0x3F)
0x40)
16
Progress Bar
void newBarTip( int i, int width) char bar
int pos // save cursor position
while( busyLCD()) pos addrLCD()   //
generate a new character at position i // set
the data pointer to the LCD CGRAM buffer
setLCDG( i8) // as a horizontal bar
(0-4)x thick moving left to right // 7 pixel
tall if ( width gt 4) width 0
else width 4 - width
for( bar0xff width gt 0 width--)
barltlt1 // bar gtgt 1 if right to
left   // fill each row (8) with the same
pattern putLCD( bar) putLCD( bar)
putLCD( bar) putLCD( bar) putLCD(
bar) putLCD( bar) putLCD( bar)
putLCD( bar) // restore
cursor position setLCDC( pos) //
newBarTip  
17
Progress Bar (cont.)
void drawProgressBar( int index, int imax, int
size) // index is the current progress value
// imax is the maximum value // size is
the number of character positions available
int i // scale the input values in the
available space int width index (size5)
/ imax // generate a character to
represent the tip newBarTip( TIP, width 5)
// user defined character 0   // draw a
bar of solid blocks for ( iwidth/5 igt0
i--) putLCD( BRICK) // filled
block character   // draw the tip of the bar
putLCD( TIP) // use character
0 // drawProgressBar
Write a Comment
User Comments (0)
About PowerShow.com