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

[Atmega8][C/WinAVR] Problem z kompilacją (string.h)

SirKamil90 06 Lis 2009 11:54 2378 5
REKLAMA
  • #1 7222565
    SirKamil90
    Poziom 14  
    Witam serdecznie, mam pewien problem przy kompilacji programu sterującego DS18B20 z biblioteki rklibavr, podczas kompilacji wyskakuje mi log:

    > "make.exe" all
    -------- begin --------
    avr-gcc -c -mmcu=atmega8 -I. -g -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=main.lst -I../../lib -Os main.c -o main.o
    main.c:4:20: error: string.h: No such file or directory
    main.c: In function 'main':
    main.c:16: warning: unused variable 'i'
    main.c:16: warning: unused variable 'diff'
    make.exe: *** [main.o] Error 1
    
    > Process Exit Code: 2
    > Time Taken: 00:01
    


    Sciągnąłem bibliotekę rklibavr ze strony domowej, nie moge w niej znaleźć pliku string.h, czy te zmienne i oraz diff są rzeczywiście potrzebne?

    Kod programu:

    #include <avr/io.h>
    #include <avr/interrupt.h>
    #include <avr/eeprom.h>
    #include <string.h>
    
    #include "delay.h"
    #include "uart.h"
    #include "lcd.h"
    #include "ds18x20.h"
    
    uint8_t gSensorIDs[OW_ROMCODE_SIZE];
    
    int main( void )
    {
    	uint16_t decicelsius;
    	uint8_t diff, i, subzero, cel, cel_frac_bits;
    
    	UART_init();
    	LCD_init();
    
    #ifndef OW_PORT
    	OW_set_bus(&PORTD,6);
    #endif
    //	DS18X20_find_sensor(&diff, &gSensorIDs[0]);
    	
    	while(1)
    	{
    //		i = gSensorIDs[0]; // family-code for conversion-routine
    
    		DS18X20_start_meas( DS18X20_POWER_PARASITE, NULL );
    		delayms(DS18B20_TCONV_12BIT);
    		DS18X20_read_meas_single(0x10, &subzero, &cel, &cel_frac_bits);
    		decicelsius = DS18X20_temp_to_decicel(subzero, cel, cel_frac_bits);
    
    //		UART_putstr_P(PSTR("\rdiff = "));
    //		UART_putint(diff, 16);
    //		UART_putstr_P(PSTR("\rgSensorIDs[0] = "));
    //		UART_putint(i, 16);
    		UART_putstr_P(PSTR("\rsubzero = "));
    		UART_putint(subzero, 10);
    		UART_putstr_P(PSTR("\rcel = "));
    		UART_putint(cel, 10);
    		UART_putstr_P(PSTR("\rcel_frac_bits = "));
    		UART_putint(cel_frac_bits, 10);
    		UART_putstr_P(PSTR("\rdecicelsius = "));
    		
    		UART_putchar((subzero)?'-':'+');
    		UART_putint( (decicelsius/10) ,10);
    		UART_putchar(',');
    		UART_putchar( (decicelsius%10) + '0');
    		UART_putchar('\r');
    		LCD_xy(0,0);
    		LCD_putchar((subzero)?'-':'+');
     		LCD_putint( (decicelsius/10) ,10);
    		LCD_putchar(',');
    		LCD_putchar( (decicelsius%10) + '0');
    	}
    		
    }


    Pozdrawiam
  • REKLAMA
  • #2 7222578
    szelus
    Poziom 34  
    Plik string.h powinien być w WinAVR. Lepiej pokaż plik Makefile i powiedz, skąd go wziąłeś.
  • REKLAMA
  • #3 7222590
    SirKamil90
    Poziom 14  
    Hm też mi się tak wydaje, nie wiem czemu go tam nie ma.. Makefile jest z folderu w którym jest cały projekt tego programu z biblioteki rklibavr.

    Makefile:

    # Nazwa pliku z funkcją main() - BEZ ROZSZERZENIA!
    TARGET = main
    
    # typ mikrokontrolera
    #MCU = at90s2313
    #MCU = at90s8515
    #MCU = atmega163
    MCU = atmega8
    #MCU = atmega128
    
    # Katalog z bibliotekami użytkownika
    USRLIB	= ../../lib
    
    # Lista plików źródłowych bibliotek w języku C
    SRCLIB =
    #include $(USRLIB)/adc_pwm/sources
    #include $(USRLIB)/conv/sources
    include $(USRLIB)/lcd/sources
    #include $(USRLIB)/i2c/sources
    #include $(USRLIB)/led7seg/sources
    #include $(USRLIB)/kbd/sources
    include $(USRLIB)/delay/sources
    #include $(USRLIB)/pcf8583/sources
    include $(USRLIB)/uart/sources
    include $(USRLIB)/onewire/sources
    include $(USRLIB)/ds18x20/sources
    
    # Lista plików źródłowych w języku C
    SRC = $(TARGET).c
    
    # Lista plików źródłowych w asemblerze (rozszerzenie S - DUŻE S !)
    ASRC = 
    
    # Format pliku wyjściowego (srec, ihex)
    FORMAT = ihex
    
    # Poziom optymalizacji (0, 1, 2, 3, s) 
    # (Uwaga: 3 nie zawsze jest najlepszym wyborem)
    OPT = s
    
    # Dodatkowe biblioteki
    #
    # Minimalna wersja printf
    #LDFLAGS += -Wl,-u,vfprintf -lprintf_min
    #
    # Zmiennoprzecinkowa wersja printf (wymaga biblioteki matematycznej)
    #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
    #
    # Biblioteka matematyczna
    #LDFLAGS += -lm
    
    include $(USRLIB)/avr_make
    
  • REKLAMA
  • #4 7222678
    szelus
    Poziom 34  
    Ten na końcu "wciąga" ../../lib/avr_make i tam jest (hmm... powinno być) to, co istotne...
  • REKLAMA
  • #5 7222686
    mirekk36
    Poziom 42  
    SirKamil90 napisał:
    Hm też mi się tak wydaje, nie wiem czemu go tam nie ma..


    jeśli u ciebie po prawidłowym zainstalowaniu WinAVR nie ma tego pliku

    C:\WinAVR-20090313\avr\include\string.h

    to albo go sobie sam skasowałeś może niechcąco - albo go gdzieś przeniosłeś itp

    Spróbuj zainstalować najnowszą wersję jeszcze raz i podejrzewam że plik się znajdzie i kompilacja ruszy przynajmniej w tym miejscu gdzie teraz ci błąd wywala. (u mnie jest ten plik dokładnie w tej lokalizacji)
  • #6 7222746
    SirKamil90
    Poziom 14  
    Udało mi się rozwiązać problem, rzeczywiście nie było po prstu pliku string.h, więc musiałem go przypadkowo usunąć.. Kompilacja przechodzi już bez problemu, muszę teraz chyba ustawić odpowiednie wartości w pliku ds18x20, jednak nie wiem na jakie, jakoś z datasheetu nie potrafie tego wyczytac.. O ile rzeczywiścei trzeba to wyczytać z dokumentacji, mam czujnik ds18b20. Wie może ktoś jakie wartości powinny być?

    Plik ds18x20.h

    #ifndef DS18X20_H_
    #define DS18X20_H_
    
    /*! \file ds18x20.h \brief Obsługa termometru 1-wire DS18x20 */
    /*
      Copyright (c) 2005 Robert Krysztof
      robert.krysztof@wp.pl
      http://www.avr-gcc.prv.pl
    */
    /** \defgroup ds18x20 Termometr 1-wire DS18x20
     
     Obsługa termometru 1-wire DS18x20.
     
     \code
     #include "ds18x20.h "
     \endcode 
     \ref config:
     
     W pliku \c "config.h" znajdującym się w katalogu projektu należy umieścić następującą zawartość:
        	     
     \code
     #define OW_PORT	PORTB
     #define OW_BIT		0
     \endcode
     
     \note Wartości z \c #define można zmieniać w celu dostosowania 
     biblioteki do tworzonego urządzenia i oprogramowania.
    */
    
    #include <stdlib.h>
    #include <inttypes.h>
    #include "onewire.h"
    
    /* return values */
    #define DS18X20_OK          0x00
    #define DS18X20_ERROR       0x01
    #define DS18X20_START_FAIL  0x02
    #define DS18X20_ERROR_CRC   0x03
    
    #define DS18X20_POWER_PARASITE 0x00
    #define DS18X20_POWER_EXTERN   0x01
    
    /* DS18X20 specific values (see datasheet) */
    #define DS18S20_ID 0x10
    define DS18B20_ID 0x28
    
    #define DS18X20_CONVERT_T	0x44
    #define DS18X20_READ		0xBE
    #define DS18X20_WRITE		0x4E
    #define DS18X20_EE_WRITE	0x48
    #define DS18X20_EE_RECALL	0xB8
    #define DS18X20_READ_POWER_SUPPLY 0xB4
    
    #define DS18B20_CONF_REG    4
    #define DS18B20_9_BIT       0
    #define DS18B20_10_BIT      (1<<5)
    #define DS18B20_11_BIT      (1<<6)
    #define DS18B20_12_BIT      ((1<<6)|(1<<5))
    
    // indefined bits in LSB if 18B20 != 12bit
    #define DS18B20_9_BIT_UNDF       ((1<<0)|(1<<1)|(1<<2))
    #define DS18B20_10_BIT_UNDF      ((1<<0)|(1<<1))
    #define DS18B20_11_BIT_UNDF      ((1<<0))
    #define DS18B20_12_BIT_UNDF      0
    
    // conversion times in ms
    #define DS18B20_TCONV_12BIT      750
    #define DS18B20_TCONV_11BIT      DS18B20_TCONV_12_BIT/2
    #define DS18B20_TCONV_10BIT      DS18B20_TCONV_12_BIT/4
    #define DS18B20_TCONV_9BIT       DS18B20_TCONV_12_BIT/8
    #define DS18S20_TCONV            DS18B20_TCONV_12_BIT
    
    // constant to convert the fraction bits to cel*(10^-4)
    #define DS18X20_FRACCONV         625
    
    #define DS18X20_SP_SIZE  9
    
    // DS18X20 EEPROM-Support
    #define DS18X20_WRITE_SCRATCHPAD  0x4E
    #define DS18X20_COPY_SCRATCHPAD   0x48
    #define DS18X20_RECALL_E2         0xB8
    #define DS18X20_COPYSP_DELAY      10 /* ms */
    #define DS18X20_TH_REG      2
    #define DS18X20_TL_REG      3
    
    
    /* for description of functions see ds18x20.c */
    
    extern void DS18X20_find_sensor(uint8_t *diff, 
    	uint8_t id[]);
    	
    extern uint8_t	DS18X20_get_power_status(uint8_t id[]);
    
    extern uint8_t DS18X20_start_meas( uint8_t with_external,
    	uint8_t id[]);
    extern uint8_t DS18X20_read_meas(uint8_t id[], 
    	uint8_t *subzero, uint8_t *cel, uint8_t *cel_frac_bits);
    extern uint8_t DS18X20_read_meas_single(uint8_t familycode,
    	uint8_t *subzero, uint8_t *cel, uint8_t *cel_frac_bits);
    
    extern uint8_t DS18X20_meas_to_cel( uint8_t fc, uint8_t *sp, 
    	uint8_t* subzero, uint8_t* cel, uint8_t* cel_frac_bits);
    extern	uint16_t DS18X20_temp_to_decicel(uint8_t subzero, uint8_t cel, 
    	uint8_t cel_frac_bits);
    extern int8_t DS18X20_temp_cmp(uint8_t subzero1, uint16_t cel1, 
    	uint8_t subzero2, uint16_t cel2);
    
    // write th, tl and config-register to scratchpad (config ignored on S20)
    uint8_t DS18X20_write_scratchpad( uint8_t id[], 
    	uint8_t th, uint8_t tl, uint8_t conf);
    // read scratchpad into array SP
    uint8_t DS18X20_read_scratchpad( uint8_t id[], uint8_t sp[]);
    // copy values th,tl (config) from scratchpad to DS18x20 eeprom
    uint8_t DS18X20_copy_scratchpad( uint8_t with_power_extern,
    	uint8_t id[] );
    // copy values from DS18x20 eeprom to scratchpad
    uint8_t DS18X20_recall_E2( uint8_t id[] );
    
    #endif
    
REKLAMA