[syntax=c]
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <inttypes.h>
#define F_OSC 11059200
#include <util/delay.h>
#define toggle(PORT, BIT) (_SFR_BYTE(PORT) ^= _BV(BIT))
#define LCD_DDR DDRA
#define LCD_PORT PORTA
#define RS 0
#define EN 1
#define D4 2
#define D5 3
#define D6 4
#define D7 5
char zwloka= 0;
char BUF_LCD[33];
char TX1[32];
volatile uint8_t dsp_1=1;
volatile uint8_t dsp_2=2;
volatile uint8_t dsp_3=3;
volatile uint8_t dsp_4=4;
volatile uint8_t dsp_5=5;
unsigned int val=1234;
unsigned char WSK_LCD=0;
void LCD_INT(void);
void LCD_HOME(void);
void LCD_POZ(unsigned char x,unsigned char y);
void LCD_1000(unsigned int x);
void LCD_WRITE_RAM(void);
void LCD_OUT(char x);
void CPY_FLASH_RAM(char TAB);
int main()
{
// _delay_ms (50);
DDRD=255;
DDRD=255;
LCD_PORT= 255;
LCD_DDR=1<<RS|1<<EN|1<<D4|1<<D5|1<<D6|1<<D7; //LINIE LCD JAKO WYJSCIA
LCD_INT();
while(1)
{
_delay_ms (1000);
LCD_WRITE_RAM();
CPY_FLASH_RAM(TX1);
}
return 0;
}
void LCD_WRITE_RAM(void)
{
LCD_POZ (1,1);
LCD_PORT |=1<<RS;
unsigned char i;
for (i=0;i<16;i++)
{
LCD_OUT(BUF_LCD[i]);
}
LCD_POZ (1,2);
LCD_PORT |=1<<RS;
for (i=16;i<32;i++)
{
LCD_OUT(BUF_LCD[i]);
}
}
void LCD_OUT(char x)
{
LCD_PORT &=~(1<<D4|1<<D5|1<<D6|1<<D7);
if(x & (1 << 4)) LCD_PORT |=1<<D4;
if(x & (1 << 5)) LCD_PORT |=1<<D5;
if(x & (1 << 6)) LCD_PORT |=1<<D6;
if(x & (1 << 7)) LCD_PORT |=1<<D7;
_delay_ms (1) ;
LCD_PORT |=1<<EN;
LCD_PORT &=~(1<<EN|1<<D4|1<<D5|1<<D6|1<<D7);
if(x & (1 << 0)) LCD_PORT |=1<<D4;
if(x & (1 << 1)) LCD_PORT |=1<<D5;
if(x & (1 << 2)) LCD_PORT |=1<<D6;
if(x & (1 << 3)) LCD_PORT |=1<<D7;
LCD_PORT |=1<<EN;
LCD_PORT &=~(1<<EN);
}
void LCD_INT(void)
{
LCD_PORT =~(1<<RS|1<<EN); //4x 0011 z pierwsza zwloka
LCD_OUT (50);
LCD_OUT (50);
LCD_OUT (40); //function set 2 linie 5x7 znakow
LCD_OUT (8); //function set dispaly off
LCD_OUT (1); //function set display on
LCD_OUT (6); //entry mode set inkrementcaja, ram statyczny
LCD_OUT (12); //
LCD_PORT |=1<<RS;
}
void LCD_1000(unsigned int x)
{
LCD_PORT |=1<<RS;
dsp_1 =x%10+48;
x = x/10;
dsp_2 =x%10+48;
x =x/10;
dsp_3 =x%10+48;
dsp_4 =x/10+48;
LCD_OUT (dsp_4);
LCD_OUT (dsp_3);
LCD_OUT (dsp_2);
LCD_OUT (dsp_1);
}
void LCD_HOME(void)
{
LCD_PORT &=~(1<<RS);
LCD_OUT (2);
_delay_ms (5) ;
}
void LCD_POZ(unsigned char x, unsigned char y)
{
LCD_PORT &=~(1<<RS);
x=x+127;
if(y==2) x=x+64;
LCD_OUT(x);
}
void CPY_FLASH_RAM (char TAB)
{
unsigned char i;
for (i=0;i<32;i++)
{
BUF_LCD[i]=pgm_read_byte(TAB[i]);
}
}
char BUF_LCD[33] = "a";
char TX1[32] PROGMEM = "abcdefghijklmnop1234567890123456";
[/syntax]Przeglądam różne materiały jednak się poddaje, w czym problem?. Przy próbie kompilacji dostaje bład w CPY_FLASH_RAM którego nie mogę rozgryźć. Reszta działa.
