Hallo Leute und frohe Weihnachten!
Ich ärger mich gerade mit printf und meinen float Werten rum, und das
auch noch an Weihnachten, aber vielleicht kann mir doch einer helfen.
Ich hab versucht in Eclipse im AVR C Linker meine Libs für die float
Ausgabe einzubinden, aber irgendwie will der nicht so recht. Ich würde
das gerne im Eclipse hin bekommen, da ich nicht extra Makefiles etc
erstellen will, sollte ja mit Eclipse gehen, denke ich.
Ich hab also unter Properties -> C/C++ Build -> Settings -> AVR C Linker
-> Libraries oben einfach die "m" und "printf_flt" mit aufgenommen.
Wenn ich dann Compiliere sieht das so aus:
1 | **** Build of configuration Debug for project oldtimer ****
|
2 |
|
3 | make all
|
4 | Building file: ../oldtimer.c
|
5 | Invoking: AVR Compiler
|
6 | avr-gcc -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega644 -DF_CPU=16000000UL -MMD -MP -MF"oldtimer.d" -MT"oldtimer.d" -c -o "oldtimer.o" "../oldtimer.c"
|
7 | Finished building: ../oldtimer.c
|
8 |
|
9 | Building target: oldtimer.elf
|
10 | Invoking: AVR C Linker
|
11 | avr-gcc -Wl,-Map,oldtimer.map -mmcu=atmega644 -o "oldtimer.elf" ./lcd.o ./oldtimer.o ./uart.o -lm -lprintf_flt
|
12 | Finished building target: oldtimer.elf
|
13 |
|
14 | Create Flash image (ihex format)
|
15 | avr-objcopy -R .eeprom -O ihex oldtimer.elf "oldtimer.hex"
|
16 | Finished building: oldtimer.hex
|
17 |
|
18 |
|
19 | **** Build Finished ****
|
Aber bei der Ausgabe bekomme ich immer noch ? anstatt meinem Float...
includiert wird folgendes:
1 | #include <stdlib.h>
|
2 | #include <stdio.h>
|
3 | #include <avr/io.h>
|
4 | #include <avr/iom644.h>
|
5 | #include <avr/interrupt.h>
|
6 | #include <avr/pgmspace.h>
|
7 | #include <string.h>
|
8 | #include <stdint.h>
|
Der Codeabschnitt sieht so aus:
1 | double distance = 12345.78;
|
2 | char first_line[16];
|
3 | sprintf(first_line,"%f %d\n\r", distance, wheel_length);
|
4 | uart_puts(first_line);
|
5 | lcd_clrscr();
|
6 | lcd_puts(first_line);
|
Vielleicht hat Jemand noch eine Idee, was ich verkehrt mache...
VG Mario