글
#include <stdio.h> #include "smart.h" void inst_clear(void); //화면클리어 void inst_return(void); //커서제일앞으로 void inst_entry(void); //커서이동방향 할당 및 전체디스플레이변화를 가능하게함 void inst_display(void); //디스플레이 설정 void inst_cursor(void); //커서무빙설정 디스플레이 방향설정 void inst_function(void); //DL:8/4bit 설정N:도트라인 설정 void data_a(void); //데이터 집어넣는 부분 void lcd_init(void); //설정한값을 넣는 부분 int main(void) { lcd_init(); data_a(); data_a(); data_a(); data_a(); data_a(); while(1); { } return 0; } void inst_clear(void) { volatile unsigned int uicnt; DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E); //DDRA방향세개를 출력으로 바꿈 DDRC = 0xFF; //DDRC방향 모두를 출력으로 바꿈 PORTA = (0<<PIN_E); PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E); DELAY(10000); PORTA=PORTA|(1<<PIN_E); DELAY(500); PORTC=0x01; DELAY(10000); PORTA=PORTA&~(1<<PIN_E); DELAY(500); } void inst_return(void) { volatile unsigned int uicnt; DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E); DDRC = 0xFF; PORTA = (0<<PIN_E); PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E); DELAY(10000); PORTA=PORTA|(1<<PIN_E); DELAY(500); PORTC=0x02; DELAY(10000); PORTA=PORTA&~(1<<PIN_E); DELAY(500); } void inst_entry(void) { volatile unsigned int uicnt; DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E); DDRC = 0xFF; PORTA = (0<<PIN_E); PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E); DELAY(10000); PORTA=PORTA|(1<<PIN_E); DELAY(500); PORTC=0x06; DELAY(10000); PORTA=PORTA&~(1<<PIN_E); DELAY(500); } void inst_display(void) { volatile unsigned int uicnt; DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E); DDRC = 0xFF; //DDRC방향 모두를 출력으로 바꿈 PORTA = (0<<PIN_E); PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E); DELAY(10000); PORTA=PORTA|(1<<PIN_E); DELAY(500); PORTC=0xF; DELAY(10000); PORTA=PORTA&~(1<<PIN_E); DELAY(500); } void inst_cursor(void) { volatile unsigned int uicnt; DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E); DDRC = 0xFF; PORTA = (0<<PIN_E); PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E); DELAY(10000); PORTA=PORTA|(1<<PIN_E); DELAY(500); PORTC=0x14; DELAY(10000); PORTA=PORTA&~(1<<PIN_E); DELAY(500); } void inst_function(void) { volatile unsigned int uicnt; DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E); DDRC = 0xFF; PORTA = (0<<PIN_E); PORTA=(0<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E); DELAY(10000); PORTA=PORTA|(1<<PIN_E); DELAY(500); PORTC=0x3C; DELAY(10000); PORTA=PORTA&~(1<<PIN_E); DELAY(500); } void data_a(void) { volatile unsigned int uicnt; DDRA = (1<<PIN_RS)|(1<<PIN_RW)|(1<<PIN_E); DDRC = 0xFF; PORTA = (0<<PIN_E); PORTA=(1<<PIN_RS)|(0<<PIN_RW)|(0<<PIN_E); DELAY(10000); PORTA=PORTA|(1<<PIN_E); DELAY(500); PORTC='A'; DELAY(10000); PORTA=PORTA&~(1<<PIN_E); DELAY(500); } void lcd_init(void) { volatile unsigned int uicnt; DELAY(500); inst_function(); inst_entry(); inst_cursor(); inst_display(); inst_clear(); inst_return(); } |
'디지털회로' 카테고리의 다른 글
20140425 (0) | 2014.04.25 |
---|---|
20140424 USART (0) | 2014.04.24 |
20144022 문자열 숫자, 출력하기 (0) | 2014.04.22 |
20140417 LCD (0) | 2014.04.17 |
20140409 WinAVR설치 (0) | 2014.04.09 |
RECENT COMMENT