/* -------------------------------------------*/
/* By CHAE Minyong, 2009.06.04. */
/* -------------------------------------------*/
#include "project.h"
#define D_BUS 0x000000ff
#define RS 0x00000800
#define RW 0x00001000
#define EN 0x00002000
#define BL 0x00004000
void LCD_Init();
void LCD_Instruction(unsigned char ucSData);
void LCD_Data(unsigned char ucSData);
void Set_font();
int main()
{
volatile unsigned int iCount = 0;
*PIO_PER = D_BUS | RS | RW | EN | BL;
*PIO_OER = D_BUS | RS | RW | EN | BL;
LCD_Init();
LCD_Instruction(0x06);//Entry mode set
LCD_Instruction(0x80);//DDRAM Address
Set_font();
while(1)
{
LCD_Instruction(0x85); //문자의 시작 위치
LCD_Data(0x06);//'♥'
LCD_Data(0x00);//'ㅊ'
LCD_Data(0x01);//'ㅐ'
LCD_Data(0x02);//'미'
LCD_Data(0x03);//'요'
LCD_Data(0x06);//'♥'
LCD_Instruction(0xC8); //2라인의 시작위치
LCD_Data(0x04);//'ㄴ'
LCD_Data(0x05);//'ㅇ'
}
return 0;
}
void LCD_Init()
{
LCD_Instruction(0x01);//Clear Display
LCD_Instruction(0x3c);//Function set
LCD_Instruction(0x0c);//Display ON/OFF Control
LCD_Instruction(0x01);//Clear Display
}
void Set_font()
{
unsigned int i;
unsigned int font[] = {
0x04, 0x04, 0x1f, 0x02, 0x04, 0x0a, 0x11, 0x00, //'ㅊ' 0x00
0x0a, 0x0a, 0x0a, 0x0e, 0x0a, 0x0a, 0x0a, 0x00, //'ㅐ' 0x01
0x00, 0x1d, 0x15, 0x15, 0x15, 0x1d, 0x00, 0x00, //'미' 0x02
0x04, 0x0a, 0x0a, 0x04, 0x0a, 0x0a, 0x1f, 0x00, //'요' 0x03
0x08, 0x08, 0x08, 0x0e, 0x00, 0x00, 0x00, 0x00, //'ㄴ' 0x04
0x06, 0x09, 0x09, 0x06, 0x00, 0x00, 0x00, 0x00, //'ㅇ' 0x05
0x00, 0x0a, 0x1f, 0x1f, 0x0e, 0x04, 0x00, 0x00};//하트 0x06
LCD_Instruction(0x40);
for(i=0; i<56; ++i) //문자가 7개 이므로 8*7만큼 저장 시킴
LCD_Data(font[i]);
}
void LCD_Instruction(unsigned char ucSData)
{
volatile unsigned int iCount = 0;
for(iCount=0;10000 >= iCount; ++iCount); //초기화를 수행하기 전의 Delay
*PIO_CODR = EN;//LCD 비활성화
*PIO_CODR = RS;//명령모드 레지스터 선택
*PIO_CODR = RW;//Write 선택
for(iCount=0;10000 >= iCount; ++iCount); // time delay Tas
*PIO_SODR = EN;//lcd enable
for(iCount=0;10000 >= iCount; ++iCount); // time delay Tdsw
*PIO_CODR = D_BUS; //dbus clear
*PIO_SODR = ucSData; //버스에 8bit 씀 set dbus
for(iCount=0;10000 >= iCount; ++iCount); // time delay Th
*PIO_CODR = EN;//EN을 H에서 L로 lcd disable
for(iCount=0;10000 >= iCount; ++iCount);
}
void LCD_Data(unsigned char ucSData)
{
volatile unsigned int iCount = 0;
for(iCount=0;10000 >= iCount; ++iCount); //초기화를 수행하기 전의 Delay
*PIO_CODR = EN;//LCD 비활성화
*PIO_SODR = RS;//명령모드 레지스터 선택
*PIO_CODR = RW;//Write 선택
for(iCount=0;10000 >= iCount; ++iCount);
*PIO_SODR = EN;//EN
for(iCount=0;10000 >= iCount; ++iCount);
*PIO_CODR = D_BUS;
*PIO_SODR = ucSData; //버스에 8bit 씀
for(iCount=0;10000 >= iCount; ++iCount);
*PIO_CODR = EN;//EN을 H에서 L로
for(iCount=0;10000 >= iCount; ++iCount);
} |