Mam taki kod:
#include <util/delay.h>
#include "lcd.h"
void LCD_SEND(unsigned char command, unsigned char komenda_lub_instrukcja)
{
if(komenda_lub_instrukcja) LCD_REJ_PORT_RS_E |= _BV(LCD_RS); // linia RS w stanie wysokim - wysłane dane będą danymi
else LCD_REJ_PORT_RS_E &= ~_BV(LCD_RS); // jeśli instrukcjami to RS w stan niski
for(unsigned int k=0;k<2;k++)
{
LCD_REJ_PORT_RS_E |= _BV(LCD_E); // linia Enable w stanie wysokim
LCD_REJ_PORT &= ~_BV(LCD_DB4) & ~_BV(LCD_DB5) & ~_BV(LCD_DB6) & ~_BV(LCD_DB7); // linie danych wyzerowane
if(command & 0b00010000) LCD_REJ_PORT |= _BV(LCD_DB4);
if(command & 0b00100000) LCD_REJ_PORT |= _BV(LCD_DB5);
if(command & 0b01000000) LCD_REJ_PORT |= _BV(LCD_DB6);
if(command & 0b10000000) LCD_REJ_PORT |= _BV(LCD_DB7);
LCD_REJ_PORT_RS_E &= ~_BV(LCD_E); // opadające zbocze Enable potwierdzające dane DB4 .. DB7
command <<= 4; // przesunięcie o 4 bity w lewo zawatości command
}
//for(unsigned int i=0; i<5; i++) _delay_us(10); // opóźnienie 50us
_delay_us(50);
}
void LCD_Czysc(void)
{
LCD_SEND(0b00000001, instrukcja); // czyść LCD
_delay_ms(2); // opóźnienie po wyczyszczeniu wyświetlacza
LCD_SEND(0b00000010, instrukcja); // powrót do HOME
_delay_ms(2);
}
void LCD_Inicjuj(void)
{
LCD_REJ_KIER |= _BV(LCD_DB4) | _BV(LCD_DB5) | _BV(LCD_DB6) | _BV(LCD_DB7); // porty wyświetlacza pracują jako wyjście
LCD_REJ_KIER_RS_E |= _BV(LCD_RS) | _BV(LCD_E); // porty RS i E
//LCD_REJ_PORT |= _BV(LCD_RS); // wysyłane dane będą instrukcjami
LCD_REJ_PORT_RS_E &= ~_BV(LCD_RS); // wysyłane dane będą instrukcjami
LCD_REJ_PORT_RS_E |= _BV(LCD_E); // linia Enable w stanie wysokim
//for(unsigned int i=0; i<5; i++) _delay_ms(10); // opóźnienie 50ms od włączenia zasilania
_delay_us(50);
LCD_REJ_PORT |= _BV(LCD_DB4) | _BV(LCD_DB5); // ustaw DB7-DB4 na 0011
LCD_REJ_PORT &= ~_BV(LCD_DB6) & ~_BV(LCD_DB7);
//_delay_us(1);
LCD_REJ_PORT_RS_E &= ~_BV(LCD_E); // opadające zbocze Enable potwierdzające dane DB4 .. DB7
_delay_ms(5); // odczekaj 5ms
LCD_REJ_PORT_RS_E |= _BV(LCD_E); // linia Enable w stanie wysokim
_delay_us(1);
LCD_REJ_PORT_RS_E &= ~_BV(LCD_E); // opadające zbocze Enable potwierdzające dane DB4 .. DB7
_delay_us(100);
//for(unsigned int i=0; i<10; i++) _delay_us(10); // opóźnienie 100us
LCD_REJ_PORT_RS_E |= _BV(LCD_E); // linia Enable w stanie wysokim
_delay_us(1);
LCD_REJ_PORT_RS_E &= ~_BV(LCD_E); // opadające zbocze Enable potwierdzające dane DB4 .. DB7
_delay_us(100);
//for(unsigned int i=0; i<10; i++) _delay_us(10); // opóźnienie 100us
LCD_REJ_PORT &= ~_BV(LCD_DB4); // ustaw DB7-DB4 na 0010
LCD_REJ_PORT_RS_E |= _BV(LCD_E); // linia Enable w stanie wysokim
//_delay_us(1);
LCD_REJ_PORT_RS_E &= ~_BV(LCD_E); // opadające zbocze Enable potwierdzające dane DB4 .. DB7
_delay_us(100);
//for(unsigned int i=0; i<10; i++) _delay_us(10); // opóźnienie 100us
//****dodatkowe parametry inicjalizacji****
LCD_SEND(0b00101000, instrukcja); // Konfiguracja sterownika- interfejs 4-bitowy, wyświetlacz 2 liniowy, matryca 5x8 punktów
LCD_SEND(0b00000110, instrukcja); // Konfiguracja trybu- imkrementacja adresu
LCD_SEND(0b00001100, instrukcja); // Konfiguracja sterowania wyświetlaczem- włącz wyświetlanie, kursow wyłączony, miganie kursora wyłączone
LCD_Czysc();
}
void LCD_Zapisz(char * text)
{
while(*text)
LCD_SEND(*text++,dane);
}
void LCD_XY(unsigned char X, unsigned char Y) // ustawia kursor na pozycji X,Y, gdzie X to nr pola poziomo a Y to nr pola w pionie. 0,0 to pozycja początkwa.
{
LCD_SEND(0b10000000 | (X + (0x40 * Y)),instrukcja);
}
void LCD_LICZBA(unsigned int n) // Wyświetla liczbę 3-cyfrową, występują zera wiodące,
{ // liczba zajmuje 3 pola od następnej niż aktualna pozycja kursowa
if(n/100)
{
LCD_SEND(48+(n/100),dane);
n%=100;
LCD_SEND(48+(n/10),dane);
}
else
{
n%=100;
if(n/10)
LCD_SEND(48+(n/10),dane);
}
n%=10;
LCD_SEND(48+n,dane);
}
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
LCD_Inicjuj();
LCD_Zapisz("Hello World!");
}
Podczas kompilacji pojawia się taki błąd:
**** Build of configuration Release for project LCD ****
make all
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
Error makefile 6: Command syntax error
Error makefile 11: Command syntax error
Error makefile 12: Command syntax error
Error makefile 13: Command syntax error
Error makefile 15: Command syntax error
Error makefile 16: Command syntax error
Error makefile 17: Command syntax error
Error makefile 18: Command syntax error
Error makefile 19: Command syntax error
Error makefile 20: Command syntax error
Error makefile 21: Command syntax error
Error makefile 22: Command syntax error
Error makefile 23: Command syntax error
Error makefile 24: Command syntax error
Error makefile 25: Command syntax error
Error makefile 26: Command syntax error
Error makefile 27: Command syntax error
Error makefile 28: Command syntax error
Error makefile 30: Command syntax error
Error makefile 89: Colon expected
Error makefile 91: Command syntax error
*** 21 errors during make ***
**** Build Finished ****
Jak naprawić ten błąd?