MSU Guest
|
Lcd-problem occur with 3.205 |
Posted: Wed Jul 14, 2004 2:44 am |
|
|
this driver works fine with 3.190, but it dont work it all with 3.205
i need help!
/thanks
Code: | #bit LcdEnable = PORTB.0
#bit LcdRS = PORTB.1
#bit LcdRW = PORTB.2
#bit LcdD4 = PORTC.0
#bit LcdD5 = PORTC.1
#bit LcdD6 = PORTC.2
#bit LcdD7 = PORTC.3
#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 64 // LCD RAM address for the second line
#define lcd_line_three 16 // LCD RAM address for the third line
#define lcd_line_four 80 // LCD RAM address for the fourth line
byte CONST LCD_INIT_STRING[4] = {(0x20 | (lcd_type << 2)), 0xc, 1, 6};
// Special characters å/Å/Ä/Ö/g/down-arrow/up-arrow/bargraph test
byte CONST FONT[64]={4,0,14,1,15,17,15,0, 4,4,10,17,31,17,17,0, 10,4,10,17,31,17,17,0, 10,14,17,17,17,17,14,0,
0,0,15,17,17,15,1,14, 0,14,14,14,31,14,4,0, 0,4,14,31,14,14,14,0, 21,21,21,21,21,21,21,0};
//********************************************************
// LCD Send nibble
//********************************************************
void lcd_send_nibble( int8 n )
{
LcdD4 = n & 1;
LcdD5 = n & 2;
LcdD6 = n & 4;
LcdD7 = n & 8;
delay_cycles(1);
LcdEnable = 1;
delay_us(2);
LcdEnable = 0;
}
//********************************************************
// LCD Send byte
//********************************************************
void lcd_send_byte( int8 address, int8 n )
{
delay_ms(2);
LcdRS = address;
delay_cycles(1);
LcdRW = 0;
delay_cycles(1);
LcdEnable = 0;
lcd_send_nibble(n >> 4);
lcd_send_nibble(n & 0xf);
}
//********************************************************
// LCD Init
//********************************************************
void lcd_init()
{
int8 i;
LcdRS = 0;
LcdRW = 0;
LcdEnable = 0;
delay_ms(15);
for(i=1;i<=3;++i)
{
lcd_send_nibble(3);
delay_ms(5);
}
lcd_send_nibble(2);
for(i=0;i<=3;++i)
lcd_send_byte(0,LCD_INIT_STRING[i]);
for(i=0;i<64;i++)
{
lcd_send_byte(0,0x40+i);
lcd_send_byte(1,FONT[i]);
}
}
//********************************************************
// LCD Goto XY
//********************************************************
void lcd_gotoxy( int8 x, int8 y)
{
int8 address;
switch (y)
{
case 2:
address=lcd_line_two;
break;
case 3:
address=lcd_line_three;
break;
case 4:
address=lcd_line_four;
break;
default:
address=0;
break;
}
address+=x-1;
lcd_send_byte(0,0x80|address);
}
//********************************************************
// LCD Putc
//********************************************************
void lcd_putc( char c)
{
switch (c)
{
case 'å':
lcd_send_byte(1,0);
break;
case 'ä':
lcd_send_byte(1,225);
break;
case 'ö':
lcd_send_byte(1,239);
break;
case 'Å':
lcd_send_byte(1,1);
break;
case 'Ä':
lcd_send_byte(1,2);
break;
case 'Ö':
lcd_send_byte(1,3);
break;
case 'g':
lcd_send_byte(1,4);
break;
case '\f':
lcd_send_byte(0,1);
delay_ms(2);
break;
case '\n':
lcd_gotoxy(1,2);
break;
case '\b':
lcd_send_byte(0,0x10);
break;
default:
lcd_send_byte(1,c);
break;
}
}
|
|
|