Printf and Tiny library

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

Printf and Tiny library

7,137 Views
LPs1978
Contributor III

Hi all,

   I'm building a project with tiny library C_4i_CF_SZ.a

 

I want to use printf to write on my LCD display.

 

My routines are ok and tested. What I want to do is to redirect the printf to my proprietary function that use my GUI. 

As usual I tryed to redirect the stdout->write_proc to my function Write_Display.

I debugged my code and I'm sure that the correct address is filled in the right position of stdout structure, but when I use printf and fflush functions my proprietary function is not colled.

 

Where is my error??

 

Thanks for your support

Labels (1)
0 Kudos
8 Replies

5,300 Views
vier_kuifjes
Senior Contributor I

You could also use sprintf to print to a string and then copy the data in the string to the LCD using some LCD driving routines.

 

That is how I do it anyway...

0 Kudos

5,300 Views
LPs1978
Contributor III

Yes, I undestand your solution, but it isn't so fast.

 

Otherwise It's a problem that I want to understand to know better the MSL library.

0 Kudos

5,300 Views
RichTestardi
Senior Contributor II

Hi,

 

If you want, you can just define your own printf() which overrides the default putchar routine, as described here:

 

http://forums.freescale.com/freescale/board/message?board.id=CWCFCOMM&message.id=2508&query.id=4632#...

 

Then you can change your putchar() routine to write to your LCD, and use printf() normally to access it.

 

There's also some background on how the whole printf path works in that thread.

 

-- Rich

0 Kudos

5,300 Views
LPs1978
Contributor III

Thanks Rich, buts I know the way you explained to me.

 

I made the same some time ago, using the entire printf_tiny_io.c in my progect linked before the MSL library with my modification.

 

What I want to understand is why, with tiny support, I cannot use the stdout with printf. Probably I have to configure something in the stdout structure to make it able to work....

0 Kudos

5,300 Views
admin
Specialist II

Did you tested the low level by sending to the same custom file descriptor using fprintf() ?

0 Kudos

5,300 Views
LPs1978
Contributor III

Yes! I tested the fprintf function with stdout.

 

I checked also that the write_proc is the correct one when teh fprintf is executed and all is ok.

 

I'm desperate.

0 Kudos

5,300 Views
admin
Specialist II

To better understand the issue, could you send using fprintf() to another (non-stdout and non-LCD) file descriptor? Say, to TCP socket?

Generally, if everything is seems correct, but isn't working, the direction of the search is wrong.

 

0 Kudos

5,300 Views
LPs1978
Contributor III

The only thing that I found is that always the printf calls WriteUARTN function. I think that is this the problem, that cause that my chars are not placed into the stdout structure.

 

Onother strange thing is that all stdout structure seems not initialize (eg. stdout->buffer_ptr = 0x0000)

0 Kudos