PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : expected expression befor '|=' token??



DarkSoldier
24.12.2012, 09:31
Hallo,

derzeit bin ich dabei mir die Sprache C beizubringen.
Ich habe nun versucht ein einfaches Programm zu schreiben, das den Roboter fahren lassen soll. Um einfach mal zu überprüfen ob ich es richtig gemacht habe, habe ich die Debugg funktion genutzt dann kahmen jedoh einige Fehlermeldungen: Error 2 expected expression before '|=' token 47 11 GccApplication2
Das Problem bezieht sich unteranderem auf folgenden Programmblock:
DDR_EIN |= (1 << PAD_EIN);
DDR_LS |= (1 << PAD_LS);
DDR_LR |= (1 << PAD_LR);
DDR_RR |= (1 << PAD_RR);
DDR_RS |= (1 << PAD_RS);
Ich weis mein Code ist noch nicht komplett aber ich habe keine Ahnung was da falsch sein soll, ich habe es mit hilfe des "Hallo Welt für AVR im RN-Wiki gemacht.

Eine zweite frage ist wie ich die Serielle Kommunication nutzen kann.

Mein Code:




#include <avr/io.h>
#include <avr/interrupt.h>

#define PAD_EIN 1;
#define PORT_EIN PORTB;
#define DDR_EIN DDRB;

#define PAD_RS 2;
#define PORT_RS PORTC;
#define DDR_RS DDRC;

#define PAD_RR 4;
#define PORT_RR PORTC;
#define DDR_RR DDRC;

#define PAD_LS 3;
#define PORT_LS PORTC;
#define DDR_LS DDRC;

#define PAD_LR 5;
#define PORT_LR PORTC;
#define DDR_LR DDRC;




int step;
char direction;

void fahren(int Schrittanzahl, char Richtung){

DDR_EIN |= (1 << PAD_EIN);
DDR_LS |= (1 << PAD_LS);
DDR_LR |= (1 << PAD_LR);
DDR_RR |= (1 << PAD_RR);
DDR_RS |= (1 << PAD_RS);


if(Richtung = 1){
PORT_RR |= (1 << PAD_RR);
}
if(Richtung = 0){
PORT_RR &= ~(1 << PAD_RR);
}

if(Richtung = 3){
PORT_LR |= (1 << PAD_LR);
}
if(Richtung = 2){
PORT_LR &= ~(1 << PAD_LR);
}

for(Schrittanzahl, Schrittanzahl >= 0; Schrittanzahl--){
PORT_LS = 0;
PORT_RS = 0;
wait_1ms (5);
PORT_LS = 1;
PORT_RS = 1;
wait_1ms (5);


}

}

void tasterabfrage(){


}




int main (void) {

step = 0;
direction = 0;


while(1) {
tasterabfrage();
fahren(step, direction);

}



return 0;
}




Danke im Vorraus und fröhlliche Weihnachten,
mfg,
DarkSoldier

radbruch
24.12.2012, 09:52
Hallo

Kein Semikolon am Ende der #define-Zeilen, delay.h eingebunden und nach "Richtung ==" geändert:


#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>

#define PAD_EIN 1
#define PORT_EIN PORTB
#define DDR_EIN DDRB

#define PAD_RS 2
#define PORT_RS PORTC
#define DDR_RS DDRC

#define PAD_RR 4
#define PORT_RR PORTC
#define DDR_RR DDRC

#define PAD_LS 3
#define PORT_LS PORTC
#define DDR_LS DDRC

#define PAD_LR 5
#define PORT_LR PORTC
#define DDR_LR DDRC




int step;
char direction;

void fahren(int Schrittanzahl, char Richtung){

DDR_EIN |= (1 << PAD_EIN);
DDR_LS |= (1 << PAD_LS);
DDR_LR |= (1 << PAD_LR);
DDR_RR |= (1 << PAD_RR);
DDR_RS |= (1 << PAD_RS);


if(Richtung == 1){
PORT_RR |= (1 << PAD_RR);
}
if(Richtung == 0){
PORT_RR &= ~(1 << PAD_RR);
}

if(Richtung == 3){
PORT_LR |= (1 << PAD_LR);
}
if(Richtung == 2){
PORT_LR &= ~(1 << PAD_LR);
}

while(Schrittanzahl--){
PORT_LS = 0;
PORT_RS = 0;
_delay_ms (5);
PORT_LS = 1;
PORT_RS = 1;
_delay_ms (5);
}

}

void tasterabfrage(void){}

int main (void) {

step = 0;
direction = 0;

while(1) {
tasterabfrage();
fahren(step, direction);
}
return(0);
}

Gruß

mic

DarkSoldier
24.12.2012, 09:55
Danke für deine schnelle antwort :)