Reputation: 1
Why is this happening? I do not see any problems. I can not sense what to fix. help me! ../1105-1.c: In function 'E_Pulse': ../1105-1.c:23:2: error: expected ';' before numeric constant ../1105-1.c:25:2: error: expected ';' before numeric constant
These errors are per function.
#include<avr/io.h>
#include<util/delay.h>
#define TLCD_RS PORTB.0
#define TLCD_RW PORTB.1
#define TLCD_E PORTB.2
#define TLCD_EN{TLCD_E = 0 ; TLCD_E = 1 ; }
#define DATA PORTC
void Port_Init(void);
void E_Pulse(void);
void Func_Set(void);
void TLCD_DATA(unsigned char);
void Init_LCD(void);
void Port_Init(void)
{
DDRB = 0xff;
DDRC = 0xff;
}
void E_Pulse(void)
{
TLCD_E = 1;
_delay_ms(5);
TLCD_E = 0;
}
void TLCD_DATA(unsigned char data)
{
DATA = data;
TLCD_EN;
}
void Init_LCD(void)
{
TLCD_E = 0;
_delay_ms(15);
Func_Set();
_delay_ms(10);
Func_Set();
_delay_ms(150);
Func_Set();
TLCD_DATA(0x0f);
E_Pulse();
TLCD_DATA(0x06);
E_Pulse();
TLCD_DATA(0x01);
E_Pulse();
}
void lcd_char(char s)
{
TLCD_RS = 1;
TLCD_DATA(s);
E_Pulse();
}
void main(void)
{
Port_Init();
Init_LCD();
lcd_char('1');
lcd_char('2');
lcd_char('3');
lcd_char('4');
while(1);
}
Upvotes: 0
Views: 155
Reputation: 1100
Getting the same error on lines 23 and 25 is a massive clue.
Commonly the error line number refers to the line after the one with the error, because that is where things become obviously wrong to the compiler.
Reproducing that function, and expanding out the macro gives the following code
void E_Pulse(void)
{
PORTB.2 = 1;
_delay_ms(5);
PORTB.2 = 0;
}
PORTB.2 is invalid code, it looks a bit like accessing a struct but struct elements can't be numbers. So the compiler gets confused and throws errors, the semicolon was a bit misleading, generally it guesses better.
This isn't the way you control GPIO pins using the AVR system. I have linked to a reasonable looking tutorial below.
http://www.elecrom.com/avr-tutorial-2-avr-input-output/
Upvotes: 1