반응형
- 시뮬레이터 -> 프로테우스 8.1 VSM
- 컴파일러 -> 코드비전 2.05
"Download" Proteus File - [Proteus] C_LCD_8Bit.zip
"Download" Source Code - [Codevision] C_LCD_8Bit.zip
<Proteus Circuit>
<Source Code>
#include <mega128.h> #include <delay.h> #define LCD_RW PORTB.1 #define LCD_RS PORTB.0 #define LCD_E PORTB.2 #define LCD_EN {PORTB.2 = 0; PORTB.2 = 1;} #define DATA PORTE void Port_Init(void) { DDRB = 0xFF; PORTB = 0x00; DDRE = 0xFF; PORTB = 0x00; } void E_Pulse(void) { LCD_E = 1; delay_ms(5); LCD_E = 0; } void LCD_DATA(unsigned char data) { DATA = data; LCD_EN; } void Func_set(void) { LCD_RW = 0; LCD_RS = 0; LCD_DATA(0x38); E_Pulse(); } void Init_LCD(void) { LCD_E = 0; delay_ms(15); Func_set(); delay_ms(10); Func_set(); delay_us(150); Func_set(); LCD_DATA(0x0F); E_Pulse(); LCD_DATA(0x06); E_Pulse(); } void lcd_char(char s) { LCD_RS = 1; LCD_DATA(s); E_Pulse(); } void lcd_disp(char x, char y) { LCD_RS = 0; LCD_RW = 0; switch(y) { case 0 : LCD_DATA(x + 0x80); break; case 1 : LCD_DATA(x + 0xC0); break; case 2 : LCD_DATA(x + 0x80 + 20); break; case 3 : LCD_DATA(x + 0xC0 + 20); break; } E_Pulse(); } void String_Out(char x, char y, char *str) { unsigned char i = 0; lcd_disp(x, y); do{ lcd_char(str[i]); } while(str[++i]!='\0'); } void main(void) { Port_Init(); Init_LCD(); String_Out(0, 0, "Character LCD"); String_Out(0, 1, "8 Bit Control"); while(1) { ; } }
반응형
'마이컴 & 프로테우스 VSM > ATmega128' 카테고리의 다른 글
- [AVR Studio4] ADC 10비트 (1) | 2018.12.26 |
---|---|
- [Codevision] DS1302 ("ds1302.h" 사용) (0) | 2016.04.12 |
- [Codevision] 그래픽 LCD ("KS0108" 128 x 64) (4) | 2016.04.04 |
- [Codevision] 그래픽 LCD ("T6963C" 240 x 128) (0) | 2016.03.29 |
- [Codevision] 캐릭터 LCD 4비트 제어 ("sprintf" 사용) (0) | 2016.03.21 |