ECE 447 Fall 2009

Download Report

Transcript ECE 447 Fall 2009

Ενσωματωμένα Συστήματα &
Μικροελεγκτές
TI MSP430
& LCDs
1
Agenda
• External LCDs
• LCD Pseudocode Example
2
ECE447: External LCD Intro
• Liquid Crystal Diplay (LCD)
• Uses less power than LEDs
• LCDs don’t emit light, they control intensity
of reflected or transmitted light
• Works well in ambient light, requires a
LED backlight for dark environments
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
ECE447: Types of LCDs
• Segmented LCDs
– Like SSDs found in watches, meters, etc.
– There’s a SoftBaugh SBLCDA4 on the experimental board
• Character-based LCDs
–
–
–
–
–
Dot-matrix display with 1-4 rows of 8-72 characters
Can typically display a set of ~256 ASCII characters
Addressed by sending a byte to define each char
Controlled with ~3bits
Included in your kit: AMOTEC ADM1602K
• Fully Graphical LCDs
– Interface only needs a few pins
– Needs a high data rate to set the value (shape, color, etc) of
each pixel
– Your cell phone!
20
ECE447: LCD Structure
21
ECE447: Biasing the LCD
• LCDs must be driven with AC not DC
– Steady voltage will cause electrolysis of liquid crystal
which will DESTROY THE DISPLAY!
– Driven with square-waves in antiphase to give Vavg =
0V, ~100Hz
– Handled by LCD Microcontroller
• Interface to MSP430 – data and instruction Registers
22
ECE447: AMOTEC 1602K
•
•
•
•
16 character by 2 line display
256 symbols for each character
Runs at 3V
Yellow LED Backlight
23
ECE447: Diagram and Pins
24
ECE 447: Character Positions and Patterns
25
ECE447: LCD Example
Init_control
Begin
Set E to 0
Set RS to 0 (instruction code)
end
LCD_clear
Begin
Set D7-D0 to Display_Clear_Code
Set E to 1
Set E to 0
Wait for LCD to process the instruction
End
LCD_write (char c)
Begin
Set RS to 1 (data input)
Set D7-D0 to c
Set E to 1
Set E to 0
Set RS to 0 (instruction)
Wait for LCD to process the instruction
End
LCD_write_string(char * s)
Begin
while (*s != End of String )
Begin
LCD_write(*s)
s++
End
End
LCD_move_cursor_to_position (int row, int column)
Begin
Set D7-D0 to DD_RAM_Address(row, column) | D7_MASK
Set E to 1
Set E to 0
Wait for LCD to process the instruction
End
26
ECE447: LCD Example – Cont’d
#define LINE2_ADDR 0x40
#define LINE3_ADDR 0x14
#define LINE4_ADDR 0x54
int DD_RAM_Addr(int row, int column)
{
switch (row) {
case 1:
return column;
case 2:
return LINE2_ADDR + column;
case 3:
return LINE3_ADDR + column;
case 4:
return LINE4_ADDR + column;
}
char *menu1[] = {"1 - AVR. TEMPERATURE", "2 – MAX TEMPERATURE", "3-AVR.
HUMIDITY", "4 - MAX. HUMIDITY"};
void display_menu(char *menu1[])
{
int i;
for (i=1; i<=4; i++)
{
LCD_move_cursor_to_position(i, 0);
LCD_write_string(menu[i-1]);
}
}
Lcd_initialize
Begin
Sequence of instructions given by the LCD specification
End
27
ECE447: Translations from Pseudocode
Assumptions
E is connected to P2.0
RS is connected to P2.1
RW is connected to ground
D7-D0 are connected to P6
Pseudocode
C
Set E to 1
#define E_SELECTOR 0x01
P2OUT |= E_SELECTOR;
Set RS to 0
#define RS_SELECTOR 0x02
P2OUT &=~RS_SELECTOR;
Set D7-D0 to Initialization_Code
#define LCD_INIT_CODE 0x30
P6OUT = LCD_INIT_CODE;
Set D7-D0 to Function_Set_Code
(8-bit data, 2-lines, 5x7 characters)
#define LCD_FUN_CODE 0x38
P6OUT = LCD_FUN_CODE;
Set D7-D0 to Clear_Code
#define LCD_CLR_CODE 0x01
P6OUT = LCD_CLR_CODE;
Set D7-D0 to DD_RAM_Address
(row, column) | D7_MASK
#define D7_MASK 0x80
P6OUT = DD_RAM_Addr(row, column) | D7_MASK;
28
Summary
• Review Timer Example from previous
Lecture
• External LCDs
• LCD Pseudocode Example
29
Αναφορές
•
Very complete example code at:
http://focus.ti.com/docs/toolsw/folders/print/msp‐exp430fg4618.html
• link labeled: “MSP430FG4618/F2013 Experimenter’s Board Software (Rev.
A)” (http://www.ti.com/litv/zip/slac129a)
Also
• LCD Fundamentals
http://ww1.microchip.com/downloads/en/AppNotes/00658a.pdf
• MSP430x4xx Family User’s Guide
http://focus.ti.com/lit/ug/slau056j/slau056j.pdf
• MSP430FG4618/F2013 Experimenter’s Board User’s Guide
http://focus.ti.com/lit/ug/slau213a/slau213a.pdf
• SBCLDA4 Spec sheet
http://www.softbaugh.com/downloads/SBLCDA4_Specification.pdf
30