Programmering av inbyggda system Demonstrationsövning 4 1 LCD Display och Grafik Demonstration och konsultation •Arbetsbokens avsnitt 5 och 6 • LCD Grafisk display •Introduktion till laboration 3 •Målsättning: Efter lektionen ska alla självständigt kunna slutföra förberedelserna inför laboration 3
33
Embed
LCD Display och Grafik Demonstration och konsultation · LCD Display och Grafik. Demonstration och konsultation • Arbetsbokens avsnitt 5 och 6 • LCD Grafisk display • Introduktion
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Programmering av inbyggda system
Demonstrationsövning 4 1
LCD Display och Grafik
Demonstration och konsultation•Arbetsbokens avsnitt 5 och 6
• LCD Grafisk display•Introduktion till laboration 3
•Målsättning: Efter lektionen ska alla självständigt kunna slutföra förberedelserna inför laboration 3
#define LCD_ON 0x3F /* Display på */ #define LCD_OFF 0x3E /* Av */#define LCD_SET_ADD 0x40 /* Set X adress (0 – 63) */ #define LCD_SET_PAGE 0xB8 /* Set Y adress (0 – 7) */#define LCD_DISP_START 0xC0 /* Start adress i display minne */ #define LCD_BUSY 0x80 /* läsa ut busy status. R/W skall vara hög */
Programmering av inbyggda system
Demonstrationsövning 4 5
Addr X 0 - 63 Addr X 0 - 63
Y 0
Y 7
cs1=1cs2=0
cs2=1cs1=0
En bit per pixel (på eller av)
Programmering av inbyggda system
Demonstrationsövning 4 6
Exempel: cs1 = 1, cs2 = 0, x addr = 7, y addr = 0
Programmering av inbyggda system
Demonstrationsövning 4 7
Exempel: cs1 = 0, cs2 = 1, x addr = 7, y addr = 0
Programmering av inbyggda system
Demonstrationsövning 4 8
Port E
#define PORT_DISPLAY_BASE 0x40021000 /* MD407 port E */#define portModer ((volatile unsigned int *) (PORT_DISPLAY_BASE)) #define portOtyper ((volatile unsigned short *)(PORT_DISPLAY_BASE+0x4)) #define portOspeedr ((volatile unsigned int *) (PORT_DISPLAY_BASE+0x8)) #define portPupdr ((volatile unsigned int *) (PORT_DISPLAY_BASE+0xC)) #define portIdr ((volatile unsigned short *)(PORT_DISPLAY_BASE+0x10)) #define portIdrHigh ((volatile unsigned char *)(PORT_DISPLAY_BASE+0x11)) #define portOdrLow ((volatile unsigned char *)(PORT_DISPLAY_BASE+0x14)) #define portOdrHigh ((volatile unsigned char *)(PORT_DISPLAY_BASE+0x14+1))
Programmering av inbyggda system
Demonstrationsövning 4 9
Konfigurera portar
void init_app(void){/* PORT E */*portModer = 0x55555555; /* all bits outputs */*portOtyper = 0x00000000; /* outputs are push/pull */*portOspeedr = 0x55555555; /* medium speed */*portPupdr = 0x55550000; /* inputs are pull up */}
Programmering av inbyggda system
Demonstrationsövning 4 10
Bekant sedan tidigare: Men det skiljer sig i detaljerna.
static void graphic_ctrl_bit_set( unsigned char x ){
*portOdrLow|= ( ~B_SELECT & x );}static void graphic_ctrl_bit_clear( unsigned char x ){