logo elektroda
logo elektroda
X
logo elektroda
REKLAMA
REKLAMA
Adblock/uBlockOrigin/AdGuard mogą powodować znikanie niektórych postów z powodu nowej reguły.

Błędy kompilacji programu C dla ATmega32 - jak je naprawić?

castro 10 Mar 2006 18:08 1274 2
REKLAMA
  • #1 2398795
    castro
    Poziom 10  
    Posty: 48
    Ocena: 1
    hej, moze ktos z was wie dlaczego sa takie błędy podczas kompilacji programu napisanego w C do ATmega32 (kompilator jest skonfigurowany - inne progzy kompiluje):


    =============================================
    #include <io.h>
    #include <stdlib.h>

    #define lcd_r, 0;
    #define lcd_e, 1;

    //funkcja opoznienia=============================
    void czekaj (unsigned long pt)
    {
    unsigned char tpl;
    for(;pt>0;pt--)
    {
    for(tpl=255;tpl!=0;tpl--);
    }
    }
    //program główny=================================
    // BIT_0 - RS
    // BIT_1 - E
    int main(void)
    {
    int i;
    DDRB=0xFF;
    for(i=3; i!=0; i--)
    {
    cbi(PORTB, lcd_e);
    PORTB=(PORTB&0x0f)|0x30;
    czekaj(1000);
    sbi(PORTB, lcd_r);

    }
    }

    oto co wyrzuca kompilator:

    Compiling: poul.c
    avr-gcc -c -mmcu=atmega32 -I. -gdwarf-2 -DF_CPU=800000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=poul.lst -std=gnu99 -MD -MP -MF .dep/poul.o.d poul.c -o poul.o
    poul.c:4:15: warning: ISO C requires whitespace after the macro name
    poul.c:5:15: warning: ISO C requires whitespace after the macro name
    poul.c: In function `main':
    poul.c:26: warning: implicit declaration of function `cbi'
    poul.c:26: error: syntax error before ',' token
    poul.c:29: warning: implicit declaration of function `sbi'
    poul.c:29: error: syntax error before ',' token
    make: *** [poul.o] Error 1
    Build failed with 2 errors and 4 warnings...


    mi opadły juz rece...
  • REKLAMA
  • #2 2398826
    Pituś Bajtuś
    Poziom 28  
    Posty: 934
    Pomógł: 137
    Ocena: 10
    Po pierwsze : po lcd_r i lcd_e nie ma przecinka tylko powinna być spacja (#define oczywiście).
    Po drugie : kompilator nie wie co to sbi i cbi (te instrukcje są już przestarzałe)
  • #3 2398832
    Mateusz-me-1990
    Poziom 16  
    Posty: 134
    Pomógł: 8
    Ocena: 326
    Ja dopiero zaczynam programować w C, ale w tym programie brakuje mi pod koniec programu komendy return 0;.
REKLAMA