Adam Adam - 9 months ago 160
C Question

Redirect printf to Console I/O on IAR Embedded Workbench

I have coded a project of mine in C on a Windows machine in the software

IAR Embedded Workbench IDE
. The project compiles and runs fine. I have a couple of
functions in my code. But the thing is that the project is intended for a microcontroller AT91SAM7X256. I've successfully built my application to run on the sram of the microcontroller, and the application was loaded successfully. But the
function is being directed to the USART port of the controller (I can only assume), and so I would like to redirect the
to display the text on my terminal I/O. Does anyone have an idea on how I can do that?

Answer Source

I use the ARM, AVR32 and MSP430 processor versions of the IAR toolchain. In each of these you have to implement your own low level functionality to handle the stdin and stdout streams. The ARM compiler manual has a section on "Standard streams for input and output" which says that you need to write your own version of the __write() function, and it provides an example version where the data is written to a memory mapped LED display.

Knowing IAR I would expect they will have a similar example for your processor/toolchain combination.