Кто работал с данным дисплеем? Уже мозги сломал. Камень М128. Порт С - данные, порт В - управление. Пишу под пингвином. Код ниже
- Код: Выделить всё • Развернуть
- #include <avr/io.h>
 #include "symbol.h"
 #define DI 3
 #define RW 4
 #define E 2
 #define CS1 6
 #define CS2 5
 #define RST 7
 void pause(unsigned int a)
 {
 unsigned int i;
 for (i=a; i>0; i--);
 }
 void lcd_dat(unsigned char data)
 {
 PORTC = data;
 PORTB |= _BV(E);
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 PORTB |= _BV(E);
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 PORTB &= ~_BV(E);
 PORTB &= ~_BV(DI);
 }
 void lcd_com(unsigned char comm)
 {
 PORTC = comm;
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 PORTB |= _BV(E);
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 PORTB &= ~_BV(E);
 }
 void gotoxy(unsigned char x, unsigned char y)
 {
 if (x<64)
 PORTB |= _BV(CS1);
 else {
 PORTB |= _BV(CS2);
 x = x-64;
 }
 lcd_com(0x40+x);
 lcd_com(0xb8+y/8);
 }
 void clear_screen(void)
 {
 unsigned char i,j;
 PORTB |= _BV(CS1) | _BV(CS2);
 for (j=0; j<64; j++)
 {
 lcd_com(0xb8+j);
 for (i=0; i<64;i++)
 lcd_dat(0x00);
 }
 }
 void wg12864_init(void)
 {
 DDRC = 0xff;
 PORTC = 0x00;
 PORTB = _BV(RST)|_BV(CS1)|_BV(CS2);
 DDRB = _BV(RST)|_BV(CS1)|_BV(CS2)|_BV(DI)|_BV(RW)|_BV(E);
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 lcd_com(0x3f);
 lcd_com(0xc0);
 lcd_com(0x40);
 lcd_com(0xb8);
 clear_screen();
 
 PORTB &=~(_BV(CS1)|_BV(CS2));
 }
 void put_pixel(const unsigned char x, const unsigned char y, const unsigned char color)
 {
 unsigned char temp=0;
 
 PORTB = _BV(RST);
 if ((x>128)||(y>64)) return;
 
 gotoxy(x,y);
 
 PORTC = 0xff;
 DDRC = 0x00;
 PORTB |= (_BV(RW)|_BV(DI));
 pause(8);
 
 PORTB |= _BV(E);
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 PORTB &= ~_BV(E);
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 PORTB |= _BV(E);
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 temp = PORTC;
 PORTB &= ~_BV(E);
 
 if (color==1) temp |= _BV(y%8);
 else temp &= ~_BV(y%8);
 
 PORTB &= ~(_BV(RW)|_BV(DI));
 DDRC = 0xff;
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 asm("nop"); asm("nop");
 gotoxy(x,y);
 lcd_dat(temp);
 PORTB = _BV(RST);
 }
 int sign(int x)
 {
 if (x<0) return -1;
 if (x>0) return 1;
 return 0;
 }
 int abs(int x)
 {
 if (x<0) return -x;
 else return x;
 }
 void line(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char color)
 {
 
 }
 void rectangle(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char color)
 {
 
 }
 void put_char(unsigned char x0, unsigned char y0, unsigned char code, unsigned char mode)
 {
 unsigned char i,x,y;
 
 x = x0;
 y = y0;
 PORTB = _BV(RST)|_BV(CS1);
 
 if((x>128)||(y>64)) return;
 for(i=0; i<6; i++) {
 if (x>=64) {
 x = x-64;
 PORTB |= _BV(CS2);
 PORTB &= ~_BV(CS1);
 }
 
 lcd_com(0x40+x);
 lcd_com(0xb8+y);
 
 if (i<=4) {
 if (mode == 1)
 lcd_dat(~sym[code][i]);
 else
 lcd_dat(sym[code][i]);
 }
 if (i==5) {
 if (mode==1)
 lcd_dat(0xff);
 else
 lcd_dat(0x00);
 }
 x = x+1;
 }
 }
 int main(void)
 {
 unsigned char data[10]={0x24,0x39,0x35,0x2f,0x24,0x25,0x86,0x26,0x32,0x30};
 unsigned char data2[8]={0x20,0x10,0x01,0x02,0x08,0x06,0x04,0x0a};
 unsigned char i;
 
 pause(40000);
 wg12864_init();
 
 for (i=0; i<10; i++)
 put_char(10+6*i, 1, data[i],1);
 
 for (i=0; i<8; i++)
 put_char(10+6*i, 3, data2[i], 0);
 
 for(;;)
 {
 
 }
 }
 [/code]
 [code]
 const char sym[][5] =
 {
 {0x3e,0x51,0x49,0x45,0x3e}, //0x00<==>0
 {0x00,0x42,0x7f,0x40,0x00}, //0x01<==>1
 {0x42,0x61,0x51,0x49,0x46}, //0x02<==>2
 {0x21,0x41,0x45,0x4b,0x31}, //0x03<==>3
 {0x18,0x14,0x12,0x7f,0x10}, //0x04<==>4
 {0x27,0x45,0x45,0x45,0x39}, //0x05<==>5
 {0x3c,0x4a,0x49,0x49,0x30}, //0x06<==>6
 {0x01,0x71,0x09,0x05,0x03}, //0x07<==>7
 {0x36,0x49,0x49,0x49,0x36}, //0x08<==>8
 {0x06,0x49,0x49,0x29,0x1e}, //0x09<==>9
 {0x7e,0x11,0x11,0x11,0x7e}, //0x0a<==>A
 {0x7f,0x49,0x49,0x49,0x36}, //0x0b<==>B
 {0x3e,0x41,0x41,0x41,0x22}, //0x0c<==>C
 {0x7f,0x41,0x41,0x22,0x1c}, //0x0d<==>D
 {0x7f,0x49,0x49,0x49,0x41}, //0x0e<==>E
 {0x7f,0x09,0x09,0x09,0x01}, //0x0f<==>F
 {0x3e,0x41,0x49,0x49,0x3a}, //0x10<==>G
 {0x7f,0x08,0x08,0x08,0x7f}, //0x11<==>H
 {0x00,0x41,0x7f,0x41,0x00}, //0x12<==>I
 {0x20,0x40,0x41,0x3f,0x01}, //0x13<==>J
 {0x7f,0x08,0x14,0x22,0x41}, //0x14<==>K
 {0x7f,0x40,0x40,0x40,0x40}, //0x15<==>L
 {0x7f,0x02,0x0c,0x02,0x7f}, //0x16<==>M
 {0x7f,0x04,0x08,0x10,0x7f}, //0x17<==>N
 {0x3e,0x41,0x41,0x41,0x3e}, //0x18<==>O
 {0x7f,0x09,0x09,0x09,0x06}, //0x19<==>P
 {0x3e,0x41,0x51,0x21,0x5e}, //0x1a<==>Q
 {0x7f,0x09,0x19,0x29,0x46}, //0x1b<==>R
 {0x46,0x49,0x49,0x49,0x31}, //0x1c<==>S
 {0x01,0x01,0x7f,0x01,0x01}, //0x1d<==>T
 {0x3f,0x40,0x40,0x40,0x3f}, //0x1e<==>U
 {0x1f,0x20,0x40,0x20,0x1f}, //0x1f<==>V
 {0x3f,0x40,0x70,0x40,0x3f}, //0x20<==>W
 {0x63,0x14,0x08,0x14,0x63}, //0x21<==>X
 {0x07,0x08,0x70,0x08,0x07}, //0x22<==>Y
 {0x61,0x51,0x49,0x45,0x43}, //0x23<==>Z
 {0x20,0x54,0x54,0x54,0x78}, //0x24<==>a
 {0x7F,0x48,0x44,0x44,0x38}, //0x25<==>b
 {0x38,0x44,0x44,0x44,0x20}, //0x26<==>c
 {0x38,0x44,0x44,0x48,0x7F}, //0x27<==>d
 {0x38,0x54,0x54,0x54,0x18}, //0x28<==>e
 {0x08,0x7E,0x09,0x01,0x02}, //0x29<==>f
 {0x0C,0x52,0x52,0x52,0x3E}, //0x2a<==>g
 {0x7F,0x08,0x04,0x04,0x78}, //0x2b<==>h
 {0x00,0x44,0x7D,0x40,0x00}, //0x2c<==>i
 {0x20,0x40,0x44,0x3D,0x00}, //0x2d<==>j
 {0x7F,0x10,0x28,0x44,0x00}, //0x2e<==>k
 {0x00,0x41,0x7F,0x40,0x00}, //0x2f<==>l
 {0x7C,0x04,0x18,0x04,0x78}, //0x30<==>m
 {0x7C,0x08,0x04,0x04,0x78}, //0x31<==>n
 {0x38,0x44,0x44,0x44,0x38}, //0x32<==>o
 {0x7C,0x14,0x14,0x14,0x08}, //0x33<==>p
 {0x08,0x14,0x14,0x18,0x7C}, //0x34<==>q
 {0x7C,0x08,0x04,0x04,0x08}, //0x35<==>r
 {0x48,0x54,0x54,0x54,0x20}, //0x36<==>s
 {0x04,0x3F,0x44,0x40,0x20}, //0x37<==>t
 {0x3C,0x40,0x40,0x20,0x7C}, //0x38<==>u
 {0x1C,0x20,0x40,0x20,0x1C}, //0x39<==>v
 {0x3C,0x40,0x30,0x40,0x3C}, //0x3a<==>w
 {0x44,0x28,0x10,0x28,0x44}, //0x3b<==>x
 {0x0C,0x50,0x50,0x50,0x3C}, //0x3c<==>y
 {0x44,0x64,0x54,0x4C,0x44}, //0x3d<==>z
 {0x7e,0x11,0x11,0x11,0x7e}, //0x3e<==>A
 {0x7f,0x49,0x49,0x49,0x33}, //0x3f<==>Б
 {0x7f,0x49,0x49,0x49,0x36}, //0x40<==>В
 {0x7f,0x01,0x01,0x01,0x03}, //0x41<==>Г
 {0x70,0x29,0x27,0x21,0x7f}, //0x42<==>Д
 {0x7f,0x49,0x49,0x49,0x41}, //0x43<==>E
 {0x77,0x08,0x7f,0x08,0x77}, //0x44<==>Ж
 {0x41,0x49,0x49,0x49,0x36}, //0x45<==>З
 {0x7f,0x10,0x08,0x04,0x7f}, //0x46<==>И
 {0x7c,0x21,0x12,0x09,0x7c}, //0x47<==>Й
 {0x7f,0x08,0x14,0x22,0x41}, //0x48<==>K
 {0x20,0x41,0x3f,0x01,0x7f}, //0x49<==>Л
 {0x7f,0x02,0x0c,0x02,0x7f}, //0x4a<==>M
 {0x7f,0x08,0x08,0x08,0x7f}, //0x4b<==>H
 {0x3e,0x41,0x41,0x41,0x3e}, //0x4c<==>O
 {0x7f,0x01,0x01,0x01,0x7f}, //0x4d<==>П
 {0x7f,0x09,0x09,0x09,0x06}, //0x4e<==>P
 {0x3e,0x41,0x41,0x41,0x22}, //0x4f<==>C
 {0x01,0x01,0x7f,0x01,0x01}, //0x50<==>T
 {0x47,0x28,0x10,0x08,0x07}, //0x51<==>У
 {0x1c,0x22,0x7f,0x22,0x1c}, //0x52<==>Ф
 {0x63,0x14,0x08,0x14,0x63}, //0x53<==>X
 {0x7f,0x40,0x40,0x40,0xff}, //0x54<==>Ц
 {0x07,0x08,0x08,0x08,0x7f}, //0x55<==>Ч
 {0x7f,0x40,0x7f,0x40,0x7f}, //0x56<==>Ш
 {0x7f,0x40,0x7f,0x40,0xff}, //0x57<==>Щ
 {0x01,0x7f,0x48,0x48,0x30}, //0x58<==>Ъ
 {0x7f,0x48,0x30,0x00,0x7f}, //0x59<==>Ы
 {0x00,0x7f,0x48,0x48,0x30}, //0x5a<==>Э
 {0x22,0x41,0x49,0x49,0x3e}, //0x5b<==>Ь
 {0x7f,0x08,0x3e,0x41,0x3e}, //0x5c<==>Ю
 {0x46,0x29,0x19,0x09,0x7f}, //0x5d<==>Я
 
 {0x20,0x54,0x54,0x54,0x78}, //0x5e<==>a
 {0x3c,0x4a,0x4a,0x49,0x31}, //0x5f<==>б
 {0x7c,0x54,0x54,0x28,0x00}, //0x60<==>в
 {0x7c,0x04,0x04,0x04,0x0c}, //0x61<==>г
 {0xe0,0x54,0x4c,0x44,0xfc}, //0x62<==>д
 {0x38,0x54,0x54,0x54,0x18}, //0x63<==>e
 {0x6c,0x10,0x7c,0x10,0x6c}, //0x64<==>ж
 {0x44,0x44,0x54,0x54,0x28}, //0x65<==>з
 {0x7c,0x20,0x10,0x08,0x7c}, //0x66<==>и
 {0x7c,0x41,0x22,0x11,0x7c}, //0x67<==>й
 {0x7c,0x10,0x28,0x44,0x00}, //0x68<==>к
 {0x20,0x44,0x3c,0x04,0x7c}, //0x69<==>л
 {0x7c,0x08,0x10,0x08,0x7c}, //0x6a<==>м
 {0x7c,0x10,0x10,0x10,0x7c}, //0x6b<==>н
 {0x38,0x44,0x44,0x44,0x38}, //0x6c<==>o
 {0x7c,0x04,0x04,0x04,0x7c}, //0x6d<==>п
 {0x7C,0x14,0x14,0x14,0x08}, //0x6e<==>p
 {0x38,0x44,0x44,0x44,0x20}, //0x6f<==>c
 {0x04,0x04,0x7c,0x04,0x04}, //0x70<==>т
 {0x0C,0x50,0x50,0x50,0x3C}, //0x71<==>у
 {0x30,0x48,0xfc,0x48,0x30}, //0x72<==>ф
 {0x44,0x28,0x10,0x28,0x44}, //0x73<==>x
 {0x7c,0x40,0x40,0x40,0xfc}, //0x74<==>ц
 {0x0c,0x10,0x10,0x10,0x7c}, //0x75<==>ч
 {0x7c,0x40,0x7c,0x40,0x7c}, //0x76<==>ш
 {0x7c,0x40,0x7c,0x40,0xfc}, //0x77<==>щ
 {0x04,0x7c,0x50,0x50,0x20}, //0x78<==>ъ
 {0x7c,0x50,0x50,0x20,0x7c}, //0x79<==>ы
 {0x7c,0x50,0x50,0x20,0x00}, //0x7a<==>ь
 {0x28,0x44,0x54,0x54,0x38}, //0x7b<==>э
 {0x7c,0x10,0x38,0x44,0x38}, //0x7c<==>ю
 {0x08,0x54,0x34,0x14,0x7c}, //0x7d<==>я
 {0x08,0x08,0x3E,0x08,0x08}, //0x7e<==>+
 {0x00,0x50,0x30,0x00,0x00}, //0x7f<==>,
 {0x08,0x08,0x08,0x08,0x08}, //0x80<==>-
 {0x20,0x10,0x08,0x04,0x02}, //0x81<==>/
 {0x23,0x13,0x08,0x64,0x62}, //0x82<==>%
 {0x00,0x36,0x36,0x00,0x00}, //0x83<==>:
 {0x00,0x00,0x02,0x05,0x02}, //0x84<==>"
 {0x00,0x00,0x00,0x00,0x00}, //0x85<==>пробел
 {0x00,0x60,0x60,0x00,0x00} //0x86<==>.
 
 };
 [/code]
 [code]
 MCU = atmega128
 CC = avr-gcc
 OBJCOPY = avr-objcopy
 CFLAGS = -mcall-prologues -Os -mmcu=$(MCU) -Wall -Wstrict-prototypes
 all: glcd_rom.hex
 clean:
 rm -f *.o *.out *.map glcd_rom.hex
 glcd_rom.hex: glcd.out
 $(OBJCOPY) -R .eeprom -O ihex glcd.out glcd_rom.hex
 glcd.out: glcd.o
 $(CC) $(CFLAGS) -o glcd.out -Wl,-Map,glcd.map,--cref glcd.o
 glcd.o: glcd.c symbol.h
 $(CC) $(CFLAGS) -c glcd.c
Кто может подсказать куда копать?


