neeed help with xmega and printf and stdout

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

Hello all,
In my most recent XMEGA project I noticed a serious problem with printf.When i try to use AVR-LIBC printf routines outside the main.c file, with two or more variables the xmega resets!

Printing within the main.c file works just fine. I have isolated this to the printf stdout routines, its certainly not the uart.
Also Printing less than two variables, only one variable works fine!

Help is greatly appreciated!

MY MICROCONTROLLER CAN BEAT THE HELL OUT OF YOUR MICROCONTROLLER /ATMEL

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

There is no magic about the putchar() macro and functions.

printf() has no notion of the arguments you give it. It can only work through its format string, and pull off arguments that match the specifiers.

So make sure that you cast any expressions to the correct type. For example, you may have a long expression when printf() expects an int.

When you are calling a prototyped function, the compiler casts the arguments for you. However a variadic function like printf() cannot do this.

In the old days before prototypes, you had to ensure the correct type of ALL arguments yourself.

Please can you post an offending printf() call. (just replace each % with a # so the forum does not complain)

David.

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

Dear David,

As soon as I posted the issue the problem seemed to unravel.

on the commandline, "locate avr-gcc" showed me something not quite kosher.

I had two versions of AVR-GCC installed!
the avr-gcc that can be installed through apt and a
'special' released version. These two seemed to bite each other causing this problem.

Basically comes down to user-error, again.

//Steven

MY MICROCONTROLLER CAN BEAT THE HELL OUT OF YOUR MICROCONTROLLER /ATMEL