‎01-03-2008
10:14 PM
4,975 Views
![KAR KAR](https://community.nxp.com/legacyfs/online/avatars/a10204_9896.gif)
KAR
Contributor I
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've looked at several posts talking about shrinking the footprint of printf-like functions by setting #define switches in header files. There is also a "Tips & Tricks" segment about this discussed here. I wish to do the opposite. I want full floating point support for printf and scanf, but I'm running into problems making it happen.
First of all, here is what I have:
CodeWarrior 6.1 Special Eddition (Under "Help->About" it states the version is 5.9.0, Build 2404)
MCF51QE64 for my target MPU
Some other related threads that I have found useful are:
CW 6.3 for ColdFire and floating point
Simple Printf on CF question
As it stands by default, I can compile printf functions with the "%f" term, but nothing will be displayed. (I'm actually using sprintf and whatever putchar function I choose.) Also, printf works fine for printing integer values (%d, etc.).
I have tried adding print.c from "C:\Program Files\Freescale\CodeWarrior for Microcontrollers V6.1\lib\hc08c\src" and modifying libdefs.h from "C:\Program Files\Freescale\CodeWarrior for Microcontrollers V6.1\lib\hc08c\include", but I getting a lot of errors. Specifically in libdefs.h I include the switch "#define LIBDEF_PRINTF_FLOATING 1".
I think others have had success with this process before, but maybe there is a quirk for the Coldfire V1 that I am not aware of. I also wonder if I should be grabing printf.c from the HC08 source directory.
Thank you in advance for any guidance you can provide.
Kevin
Solved! Go to Solution.
1 Solution
‎01-04-2008
06:40 PM
1,702 Views
![kef kef](https://community.nxp.com/legacyfs/online/avatars/a2640_2332.gif)
kef
Specialist I
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you see these files:
{install|}\ColdFire_Support\msl\MSL_C\MSL_Common\Src\printf.c
{install|}\ColdFire_Support\msl\MSL_C\MSL_Common\Src\printf_tiny_IO.c
I don't know what's the right way. I added printf_tiny_IO.c to the project and defined
#define LIBDEF_PRINTF_FLOATING 1
also I had to unsuppress code for Ten() routine, there's a #if 0 at line 197.
5 Replies
‎01-03-2008
10:59 PM
1,702 Views
![CompilerGuru CompilerGuru](https://community.nxp.com/legacyfs/online/avatars/a2891_2583.gif)
![NXP Employee NXP Employee](/html/@31A3486DB369D9771A481951B44308DB/assets/favicon-3.16x16.png)
NXP Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Be sure not to mix the tips for HC08 and for CF. The way to go for the CF V1 is to use another library,
I think the second thread you mentions tells you which one (sorry, I don't now thouse lib names out of my memory).
Using the printf.c for the HC08 (the out of of lib/hc08c/src) or libdefs.h (out of lib/hc08c/include) is not applicable for the CF V1, instead use the provided MSL library for ColdFire.
Daniel
BTW: I still think that not using printf for small the devices is the right thing to do, so maybe a specialized float printing routing and a simple string to UART output is the way to go.
I think the second thread you mentions tells you which one (sorry, I don't now thouse lib names out of my memory).
Using the printf.c for the HC08 (the out of of lib/hc08c/src) or libdefs.h (out of lib/hc08c/include) is not applicable for the CF V1, instead use the provided MSL library for ColdFire.
Daniel
BTW: I still think that not using printf for small the devices is the right thing to do, so maybe a specialized float printing routing and a simple string to UART output is the way to go.
‎01-04-2008
02:37 PM
1,702 Views
![KAR KAR](https://community.nxp.com/legacyfs/online/avatars/a10204_9896.gif)
KAR
Contributor I
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply CompilerGuru. I thought the HC08 sources might not be completely compatible with the V1, but that was the only place I could find printf.c. There isn't a subdirectory for that source for the V1 that I could find.
The default libs that were added to my project are:
I found information about the MSL from here:
I understand that printf functions are bloated and I am not concerned in this application. I just wanted to save a little time instead of writing any specialized functions.
Thanks,
Kevin
The default libs that were added to my project are:
fp_coldfire_nodiv.a
C_4i_CF_RegABI_MSL.a
C_4i_CF_RegABI_Runtime.a
I found information about the MSL from here:
{install}\Help\PDF\ColdFireV1_Build_Tools_Reference.pdfThen under "ColdFire V1 Tools --> Using MSL Libraries". I replaced the C_4i_CF_RegABI_MSL.a with the C_4i_CF_RegABI_MATH_MSL.a choice because it contained floating point manipulation. This didn't change anything. I then tried replacing the other two libraries with the various other available libraries without any luck. Is there a specific one I need to choose? Is there anything special I need to do besides changing the libraries in the project and recompiling?
I understand that printf functions are bloated and I am not concerned in this application. I just wanted to save a little time instead of writing any specialized functions.
Thanks,
Kevin
‎01-04-2008
06:40 PM
1,703 Views
![kef kef](https://community.nxp.com/legacyfs/online/avatars/a2640_2332.gif)
kef
Specialist I
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you see these files:
{install|}\ColdFire_Support\msl\MSL_C\MSL_Common\Src\printf.c
{install|}\ColdFire_Support\msl\MSL_C\MSL_Common\Src\printf_tiny_IO.c
I don't know what's the right way. I added printf_tiny_IO.c to the project and defined
#define LIBDEF_PRINTF_FLOATING 1
also I had to unsuppress code for Ten() routine, there's a #if 0 at line 197.
‎01-04-2008
08:39 PM
1,702 Views
![KAR KAR](https://community.nxp.com/legacyfs/online/avatars/a10204_9896.gif)
KAR
Contributor I
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot kef! That did the trick.
I had to also "#define LIBDEF_PRINTF_PREC 1" as well in order for it to compile. That was fine as I needed the precision feature anyway.
I also found that I did need the C_4i_CF_RegABI_MATH_MSL.a library instead of the default or I would get a link error for "frexp".
Thanks again. I hope this may be of use to others. For a heads up though, adding the floating point support added about 8 kB to my code. Ouch![Smiley Happy :smileyhappy:](http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif)
I had to also "#define LIBDEF_PRINTF_PREC 1" as well in order for it to compile. That was fine as I needed the precision feature anyway.
I also found that I did need the C_4i_CF_RegABI_MATH_MSL.a library instead of the default or I would get a link error for "frexp".
Thanks again. I hope this may be of use to others. For a heads up though, adding the floating point support added about 8 kB to my code. Ouch
![Smiley Happy :smileyhappy:](http://freescale.i.lithium.com/i/smilies/16x16_smiley-happy.gif)
‎01-05-2008
10:45 AM
1,702 Views
![kef kef](https://community.nxp.com/legacyfs/online/avatars/a2640_2332.gif)
kef
Specialist I
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are right, LIBDEF_PRINTF_PREC 1 is necessary to make it compileable.
![](/skins/images/4671C6E4C985FD94FEA7B58079714C88/responsive_peak/images/icon_anonymous_message.png)