avr Studio 4 and setting up sprintf

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Guys. Trying to use float print features etc, especially sprintf.
I am in AVRS4 so Atmel have made it quite difficult... I am using an atmega328p, which I believe comes under the AVR5 family??? Therefore I have added the AVR5 folder for linker files, and added libprintf_flt.a and libm.a, then under custom options I have added:

-Wl,-u,vfprintf
-lprintf_flt
-lm

When I do:

        for (uint8_t i = 0; i < size; i++) { 
            sprintf(buf, "array[% u] = % f\r\n", i, array[i]); 
            strcat(inpbuf, buf); 
        } 
		printf("inpbuf: % s", inpbuf);

I get:

Quote:

inpbuf: array[0] = ?

array[1] = ?

array[2] = ?

array[3] = ?

array[4] = ?

array[5] = ?


whats the missing link? (no pun intended...)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Build the code then copy/paste the actual build output such as:

Build started 7.10.2012 at 19:16:05
avr-gcc  -mmcu=atmega16 -Wall -gdwarf-2 -std=gnu99 --save-temps -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT test.o -MF dep/test.o.d  -c  ../test.c
avr-gcc -mmcu=atmega16 -Wl,-u,vfprintf  -Wl,-Map=test.map test.o myasm.o   -L"E:\WinAVR-20100110\avr\lib\avr5"  -lm -lprintf_flt  -o test.elf
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature  test.elf test.hex
avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex test.elf test.eep || exit 0
avr-objdump -h -S test.elf > test.lss
Build succeeded with 0 Warnings...

That was the build output in AS4 when I built the code that did this...

Attachment(s):