[an error occurred while processing this directive] [an error occurred while processing this directive]
Ответ: Пример для работы через порт
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)
[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]

Отправлено RSA 21 января 2002 г. 09:00
В ответ на: Графический ЖКИ PG240128-A Powertip отправлено Xpatch 20 января 2002 г. 21:11

void ReadStatus(void)
{
LCD_CD = 1;
LCD_RD = 0;
LCD_CE = 0;
temp = LCD_In;
LCD_CE = 1;
LCD_RD = 1;
}
void StatusDisp(void)
{
LCD_CD = 1;
do {
ReadStatus();
temp &= 3;
}
while (temp != 3);
}
void ReadDate(unsigned char wert)
{
LCD_CD = 0;
LCD_RD = 0;
LCD_CE = 0;
wert = LCD_In;
LCD_CE = 1;
LCD_RD = 1;
LCD_CD = 1;
}
void WriteDaten(unsigned char wert)
{
StatusDisp();
LCD_Dir = 0xff;
LCD_Out = wert;
LCD_CD = 0;
LCD_WR = 0;
LCD_CE = 0;
LCD_CE = 1;
LCD_WR = 1;
LCD_Out = 0xff;
LCD_Dir = 0;
}
void WriteKom(unsigned char wert)
{
StatusDisp();
LCD_Dir = 0xff;
LCD_Out = wert;
LCD_CD = 1;
LCD_WR = 0;
LCD_CE = 0;
LCD_CE = 1;
LCD_WR = 1;
LCD_Out = 0xff;
LCD_Dir = 0;
}
void KomWR(unsigned char Kommando)
{
StatusDisp();
WriteKom(Kommando);
}
void KomWR2(unsigned int Data1,unsigned char Kommando)
{
StatusDisp();
WriteDaten((unsigned char)Data1);
StatusDisp();
Data1 = Data1 >> 8;
WriteDaten((unsigned char)Data1);
StatusDisp();
WriteKom(Kommando);
}
void Adress(unsigned int Data1)
{
KomWR2(Data1,0x24);
}
void lcd_clear_graph()
{
int i;
Adress(G_BASE);
for(i = 0; i < 0x1800 - G_BASE;i++)
{
WriteDaten(0);
KomWR(0xc0);
}
}
void lcd_clear_text()
{
int i;
Adress(T_BASE);
for(i = 0; i < 420;i++)
{
WriteDaten(0);
KomWR(0xc0);
}
}
void lcd_setpixel(int column, int row)
{
int addr;
addr = G_BASE + (row * BYTES_PER_ROW) + (column / 8);
Adress(addr);
KomWR(0xf8|(7 - (column%8)));
}
void lcd_clrpixel(int column, int row)
{
int addr;
addr = G_BASE + (row * BYTES_PER_ROW) + (column / 8);
Adress(addr);
KomWR(0xf0|(7 - (column%8)));
}
void lcd_print(char *string)
{
int i;
unsigned char c;
for (i = 0; i < strlen(string);i++)
{
c = string[i];
if (c == 0) goto endfor;
WriteDaten(c - 0x20);
KomWR(0xc0);
}
endfor:
}
void lcd_xy(int x,int y) // позиция xy текст
{
int addr;
addr = T_BASE + (y * BYTES_PER_ROW) + x;
Adress(addr);
}
void init(void)
{
PORTD = 0xff;
DDRD = 0xfb;
DDRC = 0x00;
PORTC = 0xff;
LCD_RES = 0;
delay_ms(100);
LCD_RES = 1;
delay_ms(200);
ReadStatus();
while ((temp & 32) == 0)
// ReadStatus();
KomWR2(0,0x24);
KomWR(0xb0);
for (I = 0; I < 0x1fff;I++)
{
ReadStatus();
while ((temp & 8) == 0)
ReadStatus();
WriteDaten(0x00);
}
KomWR(0xb2); // Autowrite OFF
KomWR2(T_BASE,0x40); // Texthome 0000
KomWR2(BYTES_PER_ROW,0x41); // 30 Textspalten
KomWR2(G_BASE,0x42); // Grafikhome 0x0C00
KomWR2(BYTES_PER_ROW,0x43); // 30 Grafikspalten
KomWR2(0x0000,0x20); // Cursorpointer auf 0000
KomWR2(0x0000,0x21); //
KomWR2(T_BASE,0x24); // Adresspointer auf Texthome
KomWR(0x9c); // Text and Grafik
KomWR(0xa0); // Cursor and Block
KomWR(0x81); // Grafik and Text
}


Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru