Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

A problem in using sprintf() in AVR32

Status
Not open for further replies.

Oveis.Gharan

Full Member level 4
Full Member level 4
Joined
Oct 21, 2006
Messages
197
Helped
34
Reputation
68
Reaction score
25
Trophy points
1,308
Location
Iran
Activity points
2,503
Dear all
I use spritntf() in my code and compile with AVR32-gcc in AVR32Studio. But there is a problem when the program reaches to its end. when i eliminate sprintf() line inmy code, the wrong occurances be eliminated too.
Please say what is the wrong thing i did.
What is the solution?
Who can i use the sprintf() safely?

Thanks in advance.
 

The avr-gcc C library, avr-libc, provides the printf() family of functions. You can use them after some preparation. General details are in the avr-libc documentation for file stdio.h.

"These notes are specific to the Arduino development environment."
 
Can you attach the AVR studio project?

You probably didn't include the correct library, you have to
include <stdio.h>
add the libprintf_mil.a
ans also add to the linker -Wl,-u,vfprintf -lprintf_min

If you are trying to use it for float then ypu have to use the math library too

Alex
 
Dear Alex and Jody
Thanks for your attentions.
I refered to AVR-libC befor and i know the syntaxes.
I have included <stdio.h> too.
The sprintf() did the job correct, But my problems seems due to that the printf() writes illegal data to part of memory which related to one of the other AVR periferals and causes malfanction.

What should i do dears?
Thanks in advance.
 

To use the sprintf() you have to add the linker options and object file as well, did you add them?

To solve your problem you have to post your code or even better the AVR studio project in case the problem is related to settings.
We can't solve the problem in a theoretical level, we need the code

Alex
 

How can I add Linkeroption and object file.
I added the -Wl,-u,vfprintf -lprintf_min to Mscellaneus subsection under AVR32/GNU C Compiler in "other flag" field.
But the problem remained unfixed.
 

Sorry for the delay, I couldn't find the article

This is for floating number support but for the simple version of sprintf you just use a different command and include the min version


Alex
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top