printf problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

printf problem

3,379 Views
LPs1978
Contributor III

Hi all,

   I'm in triuble with printf. I'm trying to use the printf standard funcion, but each time I want to use it the linker give me errors. It tells me that it cannot find UART function. I think that this is a problem of the console support, but I have not idea how to disable it.

 

How I can tell toi the linker to not use UART functions?

 

Thanks in advance

Labels (1)
0 Kudos
Reply
8 Replies

1,617 Views
LPs1978
Contributor III

Has someone news about my problem?

 

There is a way to use the stdout with printf instead of console without recompile libraries?

Message Edited by LPs1978 on 2009-07-20 09:40 AM
0 Kudos
Reply

1,621 Views
admin
Specialist II

Macro using fprintf() function can be used as a simple workaround.

 

Switching stdout from UART console to another device is OS-specific. For example, well-known uC/OS uses i/O library function ReplaceStdio().

 

0 Kudos
Reply

1,621 Views
LPs1978
Contributor III

Sorry,

 

    my problem is to use the pritf as stadard output. In other words I need to modify the stdout->write_proc to a my proprietary procedure.

 

What is happening to me is that I include stdio.h an when I use printf the sistem calls WriteUARTN funztion instead of my procedure. 

 

I think that the problem is that the library wants to send to UART the output instead of stdout file structure.

 

What I can do to solve my problem??

0 Kudos
Reply

1,621 Views
admin
Specialist II

Is overloading stdout->write_proc with your proprietary procedure succeed?

 

0 Kudos
Reply

1,621 Views
LPs1978
Contributor III

Yes! with the following istrunction:

 

    stdout->write_proc = Write_Display;

 

 

But teh firmware continue to call WriteUARTN and not my Write_Display function.

 

Where is my error????

0 Kudos
Reply

1,621 Views
LPs1978
Contributor III

Probably I found out the problem.

I debugged my firmware and I saw that when the istruction

 

stdout->write_proc = Write_Display;

 

is executed the stdout->write_proc value doesn't change and still at value 0.

 

The stdout structure is allocated in RAM.

 

What can cause this strange behaviour? 

 

Thanks in advance for you support.

0 Kudos
Reply

1,621 Views
LPs1978
Contributor III

Some others news to stress you men.

 

If I watch at the address of stdout->write_proc using view-global variables codewarrior function the value is 0x200006E4.

 

In my code, if I read the address using instruction

 

__io_proc *Pippo = &stdout->write_proc;

 

the address is totally different. The address that I read is 8 byte more high instead of the real one:

0x200006EC.

 

Than when I the firmware executes the istruction

 

stdout->write_proc = Write_Display;

 

it modify another part of stdout structure.

 

This means that the software is compiling something different instead of stdout file structure.

 

Have you got any idea to make me able to run the printf correctly????

Message Edited by LPs1978 on 2009-07-21 10:38 AM
0 Kudos
Reply

1,617 Views
LPs1978
Contributor III

I'm back to stress you.

 

At the end I found the problem of FILE structure. In ansi_prefix_CF.size.h was defined no tiny library, but for MCF52221 is mandatory to use C_4i_CF_SZ library that is a small size one.

 

Now the write_proc is set correctly, but my write function isn't colled.

 

Is the tiny library able to make me use printf???

0 Kudos
Reply