--- 메인루틴은 일부분 입니다.
--- LCD 관련 루틴은 다 있습니다.
--- DATA 는 P1으로 나갑니다.
//----------------------------------------
#define LCD_RS P2.0
#define LCD_RW P2.1
#define LCD_E P2.2
/*----- LCD2 ----- PORT -----*/
#define LCD_HOME_LINE1 0x02
#define LCD_HOME_LINE2 0xc0
void busy_check2()
{
delay(100);
}
void lcd_write_inst2(BYTE i)
{
busy_check2();
LCD_RS = 0;
LCD_RW = 0;
P1 = i;
LCD_E = 1;
LCD_E = 1;
LCD_E = 1;
LCD_E = 0;
}
void func_set2()
{
busy_check2();
lcd_write_inst2( 0x38 );
}
void dsp_on2()
{
busy_check2();
lcd_write_inst2( 0x0c );
}
void entry_mode2()
{
busy_check2();
lcd_write_inst2( 0x06 );
}
void clear_display2()
{
busy_check2();
lcd_write_inst2( 0x01 );
}
void lcd_write_char2(BYTE s)
{
busy_check2();
LCD_RS = 1;
LCD_RW = 0;
P1 = s;
LCD_E = 1;
LCD_E = 1;
LCD_E = 1;
LCD_E = 0;
}
void lcd_address_set2(BYTE s)
{
busy_check2();
lcd_write_inst2( s | 0x80 );
}
void lcd_cursor_left2()
{ lcd_write_inst2(0x10); }
void lcd_cursor_right2()
{ lcd_write_inst2(0x14); }
void lcd_write_string2(string)
BYTE *string;
{ while(*string) { lcd_write_char2(*string++); } }
void LCD_init2()
{
func_set2();
dsp_on2();
entry_mode2();
clear_display2();
}
void char_2_display2(BYTE D)
{
BYTE da,ta;
da = ta = D;
da = (da >> 4) & 0x0f;
ta = ta & 0x0f;
if ( da != 0 ) { lcd_write_char2(hex_to_asc(da)); }
else { lcd_write_char2(' '); }
lcd_write_char2(hex_to_asc(ta));
}
BYTE lcd_buffer[16];
void main()
{
LCD_E = 0;
LCD_init2();
while(1) // infinite loop program
{
clear_display2();
lcd_write_inst2( LCD_HOME_LINE1 );
//1234567890123456
lcd_write_string2("TERMINAL[ ]");
lcd_write_inst2( LCD_HOME_LINE1 );
lcd_cursor_right2();
char_2_display2(recevier_sel);
}
}
--- LCD 관련 루틴은 다 있습니다.
--- DATA 는 P1으로 나갑니다.
//----------------------------------------
#define LCD_RS P2.0
#define LCD_RW P2.1
#define LCD_E P2.2
/*----- LCD2 ----- PORT -----*/
#define LCD_HOME_LINE1 0x02
#define LCD_HOME_LINE2 0xc0
void busy_check2()
{
delay(100);
}
void lcd_write_inst2(BYTE i)
{
busy_check2();
LCD_RS = 0;
LCD_RW = 0;
P1 = i;
LCD_E = 1;
LCD_E = 1;
LCD_E = 1;
LCD_E = 0;
}
void func_set2()
{
busy_check2();
lcd_write_inst2( 0x38 );
}
void dsp_on2()
{
busy_check2();
lcd_write_inst2( 0x0c );
}
void entry_mode2()
{
busy_check2();
lcd_write_inst2( 0x06 );
}
void clear_display2()
{
busy_check2();
lcd_write_inst2( 0x01 );
}
void lcd_write_char2(BYTE s)
{
busy_check2();
LCD_RS = 1;
LCD_RW = 0;
P1 = s;
LCD_E = 1;
LCD_E = 1;
LCD_E = 1;
LCD_E = 0;
}
void lcd_address_set2(BYTE s)
{
busy_check2();
lcd_write_inst2( s | 0x80 );
}
void lcd_cursor_left2()
{ lcd_write_inst2(0x10); }
void lcd_cursor_right2()
{ lcd_write_inst2(0x14); }
void lcd_write_string2(string)
BYTE *string;
{ while(*string) { lcd_write_char2(*string++); } }
void LCD_init2()
{
func_set2();
dsp_on2();
entry_mode2();
clear_display2();
}
void char_2_display2(BYTE D)
{
BYTE da,ta;
da = ta = D;
da = (da >> 4) & 0x0f;
ta = ta & 0x0f;
if ( da != 0 ) { lcd_write_char2(hex_to_asc(da)); }
else { lcd_write_char2(' '); }
lcd_write_char2(hex_to_asc(ta));
}
BYTE lcd_buffer[16];
void main()
{
LCD_E = 0;
LCD_init2();
while(1) // infinite loop program
{
clear_display2();
lcd_write_inst2( LCD_HOME_LINE1 );
//1234567890123456
lcd_write_string2("TERMINAL[ ]");
lcd_write_inst2( LCD_HOME_LINE1 );
lcd_cursor_right2();
char_2_display2(recevier_sel);
}
}