پاسخ : سوالات مربوط به LCD های کاراکتری و گرافیکی
نوشته اصلی توسط nanoware
#include <mega16.h> #define GLCD_PORT PORTB #define GLCD_RS PORTD.0 #define GLCD_RW PORTD.1 #define GLCD_CS1 PORTD.2 #define GLCD_CS2 PORTD.3 #define GLCD_RST PORTD.4 unsigned char a,b; void glcd_init(void){ DDRB=0; GLCD_RST=1; GLCD_RS=1; GLCD_RW=0; while (PINB.4==0) { }; while (PINB.7==0) { }; }; void glcd_write(char a,char b,char c) { DDRB=0; GLCD_RST=1; GLCD_RS=1; GLCD_RW=0; while (PINB.4==0) { }; while (PINB.7==0) { }; if(b<64){ GLCD_CS1=1; GLCD_CS2=0; } if(b>63){ GLCD_CS1=0; GLCD_CS2=1; b=b-64; } GLCD_RS=0; GLCD_RW=0; DDRB=0xFF; GLCD_PORT=0xB8 | a; GLCD_PORT=0x40 | b; GLCD_RW=1; GLCD_PORT=c; } void glcd_display_on(){ DDRB=0; GLCD_RST=1; GLCD_RS=1; GLCD_RW=0; while (PINB.4==0) { }; while (PINB.7==0) { }; GLCD_RW=0; GLCD_RS=0; GLCD_PORT=0x3F; }; void main(void) { PORTB=0x00; DDRB=0x00; PORTD=0x00; DDRD=0xFF; ACSR=0x80; glcd_init(); glcd_display_on(); while(1){ if(a==8){ a=0; b++; } if(b==128) { a=0; b=0; } glcd_write(a,b,170); a++; b++; }; }
#include <mega16.h> #define GLCD_PORT PORTB #define GLCD_RS PORTD.0 #define GLCD_RW PORTD.1 #define GLCD_CS1 PORTD.2 #define GLCD_CS2 PORTD.3 #define GLCD_RST PORTD.4 unsigned char a,b; void glcd_init(void){ DDRB=0; GLCD_RST=1; GLCD_RS=1; GLCD_RW=0; while (PINB.4==0) { }; while (PINB.7==0) { }; }; void glcd_write(char a,char b,char c) { DDRB=0; GLCD_RST=1; GLCD_RS=1; GLCD_RW=0; while (PINB.4==0) { }; while (PINB.7==0) { }; if(b<64){ GLCD_CS1=1; GLCD_CS2=0; } if(b>63){ GLCD_CS1=0; GLCD_CS2=1; b=b-64; } GLCD_RS=0; GLCD_RW=0; DDRB=0xFF; GLCD_PORT=0xB8 | a; GLCD_PORT=0x40 | b; GLCD_RW=1; GLCD_PORT=c; } void glcd_display_on(){ DDRB=0; GLCD_RST=1; GLCD_RS=1; GLCD_RW=0; while (PINB.4==0) { }; while (PINB.7==0) { }; GLCD_RW=0; GLCD_RS=0; GLCD_PORT=0x3F; }; void main(void) { PORTB=0x00; DDRB=0x00; PORTD=0x00; DDRD=0xFF; ACSR=0x80; glcd_init(); glcd_display_on(); while(1){ if(a==8){ a=0; b++; } if(b==128) { a=0; b=0; } glcd_write(a,b,170); a++; b++; }; }
دیدگاه