(Answer) (Category) ImageCraft Products FAQ-O-Matic : (Category) ICCAVR V6 - and - ICC7 for AVR :
V7 -- difficulty using printf() and puts() -- !ERROR Function 'putchar' not defined
Q: I have a program that uses printf or puts, and when building the project, I get the follow error. What does it mean? It used to work with V6 compiler!

  !ERROR Function 'putchar' not defined. This is a hardware dependent function,
  and it is not included in the ICCAVR default library. Please implement
  this function to match your target requirements. You can find examples
  of this function under the <install root>\examples.AVR directory. Make
  a copy of a suitable example, add it to your project and modify it if
  needed. You must #include the C header file (e.g. stdio.h) containing
  both the function prototype and the "#pragma device_specific_function..."
  statement in your source file(s) referencing 'putchar'.

A: For printf or puts to work, you must have a putchar() function that works for the target device. Previously the putchar in the library only works for some of the AVR chips, and for a portion of the users, the program will link successfully but then it will not work. There is no way to make a putchar() that works for all devices since Atmel places the UART IO register at different locations based on the AVR chip. The error describes exactly what needs to be done.
richard@imagecraft.com

[Append to This Answer]
Previous: (Answer) I use a lot of printf calls and the strings are taking up valuable RAM space!
Next: (Answer) 'text' area size too large (>64K bytes). Please move some code to another file
This document is: http://www.dragonsgate.net/cgi-bin/FAQ/fom?file=209
[Search] [Appearance]
This is a Faq-O-Matic 2.721.
This FAQ administered by Richard Man