- LiFePO4 Speicher Test         
Ergebnis 1 bis 3 von 3

Thema: expected expression befor '|=' token??

  1. #1
    Benutzer Stammmitglied
    Registriert seit
    23.05.2011
    Beiträge
    55

    expected expression befor '|=' token??

    Anzeige

    LiFePo4 Akku selber bauen - Video
    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:


    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
    Geändert von DarkSoldier (24.12.2012 um 09:51 Uhr)

  2. #2
    Moderator Robotik Visionär Avatar von radbruch
    Registriert seit
    27.12.2006
    Ort
    Stuttgart
    Alter
    61
    Beiträge
    5.799
    Blog-Einträge
    8
    Hallo

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

    Code:
    #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
    Bild hier  
    Atmel’s products are not intended, authorized, or warranted for use
    as components in applications intended to support or sustain life!

  3. #3
    Benutzer Stammmitglied
    Registriert seit
    23.05.2011
    Beiträge
    55
    Danke für deine schnelle antwort

Ähnliche Themen

  1. Error 35: 3 parameters expected
    Von Ramer im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 3
    Letzter Beitrag: 28.02.2010, 20:05
  2. regular expression Atmega32
    Von walterk im Forum C - Programmierung (GCC u.a.)
    Antworten: 2
    Letzter Beitrag: 26.12.2009, 08:29
  3. Typedef-Problem (Expected Declaration Specifiers etc...)
    Von Jaecko im Forum C - Programmierung (GCC u.a.)
    Antworten: 2
    Letzter Beitrag: 24.08.2008, 17:29
  4. WINAVR: Warning: expression dangerous with linker stubs
    Von Kaiser-F im Forum C - Programmierung (GCC u.a.)
    Antworten: 6
    Letzter Beitrag: 14.03.2008, 19:46
  5. Error : 35 - 3 parameters expected
    Von Powell im Forum Basic-Programmierung (Bascom-Compiler)
    Antworten: 3
    Letzter Beitrag: 29.06.2007, 11:54

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Labornetzteil AliExpress