Gast
#991152
Hallo allerseits, ich hoffe mir kann jemand bei meinem kleinen Problem weiterhelfen... Ich bin noch ziemlich in den Kinderstuben was WinAVR und AVR Programmierung in C angeht. Der unten angefügte Quelltext nutzt den EEPROM vom Atmel(mega32) um Fonts für ein LCD Display dort abzuspeichern. Ich möchte gern das anlegen der EEPROM Daten und eeprom_read_block entfernen und anstattdessen den Data Code direkt mit im Flash einbinden. Also kurz gesagt das EEPROM nicht benutzen in die Data Zeilen direkt mit in den FLASH einbinden. Ich weiss das die Zeile: " eeprom_read_block(cbuff+1,font + (value-32)*5,5); //read character from eeprom to buffer " die Fontdaten vom EEPROM ausliest und diese in ein Buffer schreibt und " __attribute__((section(".eeprom"))) unsigned char font[] = { " die Data Sektion für das EEPROM ist. Folgender Quelltext ist auf das wesentliche gekürzt: grafik.c ------------------------------------------------------------------------ --- //output a character at position x,y with size 0,1 or 2,forground color fc and background color bc // size = 0 -> character size 6x8 // 1 -> character size 6x15 // 2 -> character size 11x15 void lcd_putchar(int x,int y,int value,int size,unsigned char fc,unsigned char bc) { unsigned char cbuff[6]; register int x1,y1,bit; if(value>122) { switch(value) { case 228 : value = 127; break; case 246 : value = 128; break; case 252 : value = 129; break; case 196 : value = 130; break; case 214 : value = 131; break; case 220 : value = 132; break; case 223 : value = 133; break; default : break; } } cbuff[0] = 0; //first row always 0 eeprom_read_block(cbuff+1,font + (value-32)*5,5); //read character from eeprom to buffer int xsize = 6; int ysize = 8; if(size==1) ysize = 15; if(size==2) { xsize = 11; ysize = 15; } lcd_window(x,y,x+xsize-1,y+ysize-1); for(y1=0;y1<ysize;y1++) { for(x1=0;x1<xsize;x1++) { switch(size) { case 0: bit = cbuff[x1]&(1<<y1); break; case 1: bit = cbuff[x1]&(1<<(y1/2)); break; case 2: bit = cbuff[(x1+1)/2]&(1<<(y1/2)); break; default: bit = 0; break; } if(bit) //forground pixel lcd_data(fc); else //background pixel lcd_data(bc); } } } __attribute__((section(".eeprom"))) unsigned char font[] = { 0x00 , 0x00 , 0x00 , 0x00 , 0x00, //Begins at 0x20 0x00 , 0x06 , 0x5F , 0x06 , 0x00, //0x21 0x07 , 0x03 , 0x00 , 0x07 , 0x03, //0x22 0x24 , 0x7E , 0x24 , 0x7E , 0x24, //0x23 0x24 , 0x2B , 0x6A , 0x12 , 0x00, //0x24 0x63 , 0x13 , 0x08 , 0x64 , 0x63, //0x25 0x36 , 0x49 , 0x56 , 0x20 , 0x50, //0x26 0x00 , 0x07 , 0x03 , 0x00 , 0x00, //0x27 0x00 , 0x3E , 0x41 , 0x00 , 0x00, //0x28 0x00 , 0x41 , 0x3E , 0x00 , 0x00, //0x29 0x08 , 0x3E , 0x1C , 0x3E , 0x08, //0x2a 0x08 , 0x08 , 0x3E , 0x08 , 0x08, //0x2b 0x00 , 0xE0 , 0x60 , 0x00 , 0x00, //0x2c 0x08 , 0x08 , 0x08 , 0x08 , 0x08, //0x2d 0x00 , 0x60 , 0x60 , 0x00 , 0x00, //0x2e 0x20 , 0x10 , 0x08 , 0x04 , 0x02, //0x2f 0x3E , 0x51 , 0x49 , 0x45 , 0x3E, //0x30 0x00 , 0x42 , 0x7F , 0x40 , 0x00, //0x31 0x62 , 0x51 , 0x49 , 0x49 , 0x46, //0x32 0x22 , 0x49 , 0x49 , 0x49 , 0x36, //0x33 0x18 , 0x14 , 0x12 , 0x7F , 0x10, //0x34 0x2F , 0x49 , 0x49 , 0x49 , 0x31, //0x35 0x3C , 0x4A , 0x49 , 0x49 , 0x30, //0x36 0x01 , 0x71 , 0x09 , 0x05 , 0x03, //0x37 0x36 , 0x49 , 0x49 , 0x49 , 0x36, //0x38 0x06 , 0x49 , 0x49 , 0x29 , 0x1E, //0x39 0x00 , 0x6C , 0x6C , 0x00 , 0x00, //0x3a 0x00 , 0xEC , 0x6C , 0x00 , 0x00, //0x3b 0x08 , 0x14 , 0x22 , 0x41 , 0x00, //0x3c 0x24 , 0x24 , 0x24 , 0x24 , 0x24, //0x3d 0x00 , 0x41 , 0x22 , 0x14 , 0x08, //0x3e 0x02 , 0x01 , 0x59 , 0x09 , 0x06, //0x3f 0x3E , 0x41 , 0x5D , 0x55 , 0x1E, //0x40 -> @ 0x7E , 0x09 , 0x09 , 0x09 , 0x7E, //0x41 -> A 0x7F , 0x49 , 0x49 , 0x49 , 0x36, //0x42 -> B 0x3E , 0x41 , 0x41 , 0x41 , 0x22, //0x43 -> C 0x7F , 0x41 , 0x41 , 0x41 , 0x3E, //0x44 -> E 0x7F , 0x49 , 0x49 , 0x49 , 0x41, //0x45 -> F 0x7F , 0x09 , 0x09 , 0x09 , 0x01, 0x3E , 0x41 , 0x49 , 0x49 , 0x7A, 0x7F , 0x08 , 0x08 , 0x08 , 0x7F, 0x00 , 0x41 , 0x7F , 0x41 , 0x00, 0x30 , 0x40 , 0x40 , 0x40 , 0x3F, 0x7F , 0x08 , 0x14 , 0x22 , 0x41, 0x7F , 0x40 , 0x40 , 0x40 , 0x40, 0x7F , 0x02 , 0x04 , 0x02 , 0x7F, 0x7F , 0x02 , 0x04 , 0x08 , 0x7F, 0x3E , 0x41 , 0x41 , 0x41 , 0x3E, 0x7F , 0x09 , 0x09 , 0x09 , 0x06, 0x3E , 0x41 , 0x51 , 0x21 , 0x5E, 0x7F , 0x09 , 0x09 , 0x19 , 0x66, 0x26 , 0x49 , 0x49 , 0x49 , 0x32, 0x01 , 0x01 , 0x7F , 0x01 , 0x01, 0x3F , 0x40 , 0x40 , 0x40 , 0x3F, 0x1F , 0x20 , 0x40 , 0x20 , 0x1F, 0x3F , 0x40 , 0x3C , 0x40 , 0x3F, 0x63 , 0x14 , 0x08 , 0x14 , 0x63, 0x07 , 0x08 , 0x70 , 0x08 , 0x07, 0x71 , 0x49 , 0x45 , 0x43 , 0x00, 0x00 , 0x7F , 0x41 , 0x41 , 0x00, 0x02 , 0x04 , 0x08 , 0x10 , 0x20, 0x00 , 0x41 , 0x41 , 0x7F , 0x00, 0x04 , 0x02 , 0x01 , 0x02 , 0x04, 0x80 , 0x80 , 0x80 , 0x80 , 0x80, 0x00 , 0x03 , 0x07 , 0x00 , 0x00, 0x20 , 0x54 , 0x54 , 0x54 , 0x78, 0x7F , 0x44 , 0x44 , 0x44 , 0x38, 0x38 , 0x44 , 0x44 , 0x44 , 0x28, 0x38 , 0x44 , 0x44 , 0x44 , 0x7F, 0x38 , 0x54 , 0x54 , 0x54 , 0x18, 0x08 , 0x7E , 0x09 , 0x09 , 0x00, 0x18 , 0xA4 , 0xA4 , 0xA4 , 0x7C, 0x7F , 0x04 , 0x04 , 0x78 , 0x00, 0x00 , 0x00 , 0x7D , 0x00 , 0x00, 0x40 , 0x80 , 0x84 , 0x7D , 0x00, 0x7F , 0x10 , 0x28 , 0x44 , 0x00, 0x00 , 0x00 , 0x7F , 0x40 , 0x00, 0x7C , 0x04 , 0x18 , 0x04 , 0x78, 0x7C , 0x04 , 0x04 , 0x78 , 0x00, 0x38 , 0x44 , 0x44 , 0x44 , 0x38, 0xFC , 0x44 , 0x44 , 0x44 , 0x38, 0x38 , 0x44 , 0x44 , 0x44 , 0xFC, 0x44 , 0x78 , 0x44 , 0x04 , 0x08, 0x08 , 0x54 , 0x54 , 0x54 , 0x20, 0x04 , 0x3E , 0x44 , 0x24 , 0x00, 0x3C , 0x40 , 0x20 , 0x7C , 0x00, 0x1C , 0x20 , 0x40 , 0x20 , 0x1C, 0x3C , 0x60 , 0x30 , 0x60 , 0x3C, 0x6C , 0x10 , 0x10 , 0x6C , 0x00, 0x9C , 0xA0 , 0x60 , 0x3C , 0x00, 0x64 , 0x54 , 0x54 , 0x4C , 0x00, 0x08 , 0x3E , 0x41 , 0x41 , 0x00, 0x00 , 0x00 , 0x7F , 0x00 , 0x00, 0x00 , 0x41 , 0x41 , 0x3E , 0x08, 0x02 , 0x01 , 0x02 , 0x01 , 0x00, 0x20 , 0x55 , 0x54 , 0x55 , 0x78, 0x38 , 0x45 , 0x44 , 0x45 , 0x38, 0x3C , 0x41 , 0x20 , 0x7D , 0x00, 0x7C , 0x0B , 0x0A , 0x0B , 0x7C, 0x3C , 0x43 , 0x42 , 0x43 , 0x3C, 0x3E , 0x41 , 0x40 , 0x41 , 0x3E, 0x7E , 0x2A , 0x2A , 0x2A , 0x14 }; grafik.h ------------------------------------------------------------------------ --- #ifndef __GRAFIK__H #define __GRAFIK__H #include <ctype.h> #include <stdint.h> #include <stdio.h> #include <avr/io.h> #include <avr/pgmspace.h> #include <util/delay.h> void lcd_init(void); void lcd_cmd(unsigned char value); void lcd_data(unsigned char value); void lcd_cls(unsigned char color); void lcd_window(int x1,int y1,int x2,int y2); void lcd_box(int x1,int y1,int x2,int y2,unsigned char color); void lcd_putimage(int x1,int y1,prog_uchar *image); void lcd_print(char *text,int x,int y,int size,unsigned char fc,unsigned char bc); void lcd_putchar(int x,int y,int value,int size,unsigned char fc,unsigned char bc); void lcd_msgdlg(char *title,char *text); extern unsigned char font[]; #define GLUE(a, b) a##b #define PORT(x) GLUE(PORT, x) #define PIN(x) GLUE(PIN, x) #define DDR(x) GLUE(DDR, x) #define LCD_PORT D #define LCD_RS 3 #define LCD_SD 4 #define LCD_SC 5 #define LCD_CS 6 #define Blau 0x03 #define Gelb 0xfc #define Rot 0xe0 #define Gruen 0x1C #define Schwarz 0 #define Weiss 0xff #define Hellgruen 0x3e #define Dunkelgruen 0x14 #define Dunkelrot 0xa0 #define Dunkelblau 0x02 #define Hellblau 0x1f #define Orange 0xf8 #endif ------------------------------------------------------------------------ --- Ich bin wirklich für jede Hilfe sehr dankbar, da ich mit meinen Kenntnissen und Stundenlangen lesen und suchen im Internet bisher nicht weitergekommen bin um dieses umzusetzen. Freundliche Grüße Denny