Ok das hilft mir schon mal weiter. Aber ich bekomme immer Fehlermeldungen beim erstellen meiner Datei.
Code:>Session Environment Variables: AF_AVRDIR=C:\WinAVR AF_PROJECT=test AF_SOURCE_FILES=test.c i2c.c AF_ASM_SRC_FILES= AF_PRGDIR=C:\Programme\AsuroFlash AF_PRJDIR=C:\AsuroFlash\asuro-lib\examples\US AF_ASURO_LIB_PATH=C:\AsuroFlash\asuro-lib\lib File test.c saved. >Default make_all.cmd file created. >Default makefile created. Make C:\AsuroFlash\asuro-lib\examples\US>C:\WinAVR\utils\bin\make.exe all set -e; avr-gcc -MM -mmcu=atmega8 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=test.lst -IC:\Programme\AsuroFlash\include test.c \ | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > test.d; \ [ -s test.d ] || rm -f test.d -------- begin -------- avr-gcc --version avr-gcc (WinAVR 20090313) 4.3.2 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Size before: test.elf : section size addr .text 714 0 .bss 17 8388704 .stab 888 0 .stabstr 95 0 .debug_aranges 128 0 .debug_pubnames 335 0 .debug_info 1165 0 .debug_abbrev 592 0 .debug_line 1025 0 .debug_frame 240 0 .debug_str 502 0 .debug_loc 106 0 Total 5807 avr-gcc -c -mmcu=atmega8 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=test.lst -IC:\Programme\AsuroFlash\include test.c -o test.o test.c: In function 'read_pcf8591_adc': test.c:12: warning: passing argument 1 of 'StartI2C' makes integer from pointer without a cast test.c:18: warning: passing argument 1 of 'StartI2C' makes integer from pointer without a cast test.c: In function 'main': test.c:42: warning: passing argument 1 of 'SerWrite' makes pointer from integer without a cast avr-gcc -mmcu=atmega8 -I. -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-ahlms=test.o -IC:\Programme\AsuroFlash\include test.o i2c.o --output test.elf -Wl,-Map=test.map,--cref -IC:\Programme\AsuroFlash\lib -lm test.o: In function `read_pcf8591_adc': C:\AsuroFlash\asuro-lib\examples\US/test.c:17: undefined reference to `Sleep' test.o: In function `main': C:\AsuroFlash\asuro-lib\examples\US/test.c:35: undefined reference to `Init' C:\AsuroFlash\asuro-lib\examples\US/test.c:37: undefined reference to `FrontLED' C:\AsuroFlash\asuro-lib\examples\US/test.c:42: undefined reference to `SerWrite' make: *** [test.elf] Error 1 ExitCode 2 >Ready.
Hier mal das Programm. Es soll den Wert von dem ersten Eingang vom PCF8591 über die serielle Schnittstelle senden.
Code:#include "asuro.h" #include "i2c.h" #define pcf8591_address 0x90 // I2C Adresse des PCF8574 //liest einen ADC Wert vom PCF8591 unsigned char read_pcf8591_adc(unsigned char adc) { unsigned char ret; unsigned char byte = 0; ret = StartI2C(pcf8591_address+WriteI2C); // Sende Start Condition if (ret == 0) ret = WriteI2C(adc); // Senden des Control Bytes startet die A/D Wandlung StopI2C(); // Sende Stop Condition, Bus freigeben Sleep(10); // Warten bis A/D Wandlung benedet (mind. 90µs) ret = StartI2C(pcf8591_address+ReadI2C); // Sende Start Condition if (ret == 0) { // Mehrmaliges Lesen um alte A/D Werte zu ignorieren byte = ReadI2C(1); // Lese Byte + acknowledge byte = ReadI2C(0); // Lese Byte + no acknowledge } else ret = 3; StopI2C(); // Sende Stop Condition, Bus freigeben return byte; } int main(void) { unsigned char rled; unsigned char port; Init(); InitI2C(); FrontLED(ON); while(1) { port=0; rled = read_pcf8591_adc(port); SerWrite(rled,4); } return 0; }







Zitieren

Lesezeichen