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.

[AVR] PRINTF not working in AVR Studio 7

Status
Not open for further replies.

Adbadb

Junior Member level 1
Junior Member level 1
Joined
Jan 14, 2015
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
118
Ok, so suddenly printf is not working in AVR studio, i dont know what happened, this is the code, but it doesn't output anything to the debug window:

Code:
#include <avr/io.h>
#include <stdlib.h>

int main(void)
{
	while(1)
	{
    printf("a");
	}
}
 

You should include the stdio.h file.
 
  • Like
Reactions: Adbadb

    Adbadb

    Points: 2
    Helpful Answer Positive Rating
so suddenly printf is not working in AVR studio
So I assume that your "printf" has worked before?
You haven't given us the complete setup code for "printf"

Give us the code.
 

You should include the stdio.h file.

Yes, i did but still nothing on output.
Code:
#include <avr/io.h>
#include <stdio.h>

int main(void)
{
	while(1)
	{
    printf("a");
	}
}

***merged post ***


It was, but it suddently stoped, and now it doesent work in any code, this is the simplest code possble to check if its working and still nothing on output.
And yes i included the <stdio.h> file, but still the same.
 
Last edited by a moderator:

doesn't need UART configuration ?
 

No, there is output window where it should write what is in the printf statement, but it doesn't output anything.
 

it suddently stoped, and now it doesent work in any code

Seem more reasonable that a problem occurred at the hardware scope either of your board or your computer like a component burned. The code do not suddenly stop working unless you had changed some file.
 

Yes i know, i even reinstalled Atmel Studio and it is still the same, the code above is very simple and i think it should work, it is very strange.
 

Try connecting another PC/Laptop to your station and open another HiperTerminal to check if there exists a problem with the serial cable ( although I still suspect that your reinstall bugged something ).
 

No there is no serial cable, in the Atmel Studio 7 there is output window where you can test the code, it should show up there, except if i have some mistake in the code or some i cant think of another reason.
 

It seems that there is not a problem with your code (except for the stdio.h missing). Your re-install deleted or replaced the value of a previous setting the Printf output that has not been saved in the project, but kept in the IDE.
 

Yes but in the new installation i made new project and just copied the code, i think by default the output window should work, still the same. If the code is ok, then the problem must be in Atmel Studio, this is a new version, maybe there is a bug, but highly unlikely.
 

I'm working as embedded C programmer last 5 years. You know, how many times I used printf function? Never.
 

Well its a simple way to see if something is working or not. That's why i need it.
 

Simple way is to use stm with realtime debugging and forget about avr, pic and similar ))
 

You know, how many times I used printf function? Never.

Instead of using the printf() function, I also prefer manage myself the outflow of the putc(). Unless using it inside a code runing on a RTOS, the printf() often locks the program there while not finished sending all characters.
 

Yes but i think putc() doesent work in simulation.
 

Yes but i think putc() doesent work in simulation.

Make a test to check. According to the best practices in programming, the Printf() function should be built by recursive calls of the putc() function, so considering that both are directed to the same media, should work.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top