Redlib floating point support with MCUXpresso IDE

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

Redlib floating point support with MCUXpresso IDE

Redlib floating point support with MCUXpresso IDE

Many times I came across one issue while using Redlib in MXUXpresso IDE project. I like to provide some guidance here to match the proper solution that can help others.

Problem Statement :

printf or sprintf doesn't print anything or printing random characters while using Redlib library.

Reason :

When you are creating your project you may ask to choose the c/c++ library setting to select either of the c libray provided by IDE in Advanced project setting wizard.

If you have not checked the option "Redlib: Use floating point version of printf" (which will use the floating-point variant of printf) have tried to print the floating point value, You will end up with the problem mentioned above.

Solution :

You need to enable the floating support by modifying some preprocessor directives in "Defined symbols (-D)" wizard of your project. Path :  Your Project > properties > C/C++ Build > Setiings > Tool Settings > MCU C Compiler > Preprocessor. These are:

  • PRINTF_FLOAT_ENABLE - keep the directive value to "1"
  • SCANF_FLOAT_ENABLE - keep the directive value to "1"
  • CR_INTEGER_PRINTF - Undefine/Remove this directive
  • Click on Apply and close.

That is it. Now you will have your expected prints for floating point values in your debugger console.

%3CLINGO-SUB%20id%3D%22lingo-sub-1109930%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERedlib%20floating%20point%20support%20with%20MCUXpresso%20IDE%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1109930%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EMany%20times%20I%20came%20across%20one%20issue%20while%20using%20Redlib%20in%20MXUXpresso%20IDE%20project.%20I%20like%20to%20provide%20some%20guidance%20here%20to%20match%20the%20proper%20solution%20that%20can%20help%20others.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%233366ff%3B%22%3E%3CSTRONG%3EProblem%20Statement%20%3A%3C%2FSTRONG%3E%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Eprintf%20or%20sprintf%20doesn't%20print%20anything%20or%20printing%20random%20characters%20while%20using%20Redlib%20library.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%233366ff%3B%22%3E%3CSTRONG%3EReason%20%3A%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%22%3EWhen%20you%20are%20creating%20your%20project%20you%20may%20ask%20to%20choose%20the%20c%2Fc%2B%2B%20library%20setting%20to%20select%20either%20of%20the%20c%20libray%20provided%20by%20IDE%20in%20Advanced%20project%20setting%20wizard.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%22%3EIf%20you%20have%20not%20checked%20the%20option%20%22Redlib%3A%20Use%20floating%20point%20version%20of%20printf%22%20(which%20will%20use%20the%20floating-point%20variant%20of%20printf)%20have%20tried%20to%20print%20the%20floating%20point%20value%2C%20You%20will%20end%20up%20with%20the%20problem%20mentioned%20above.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%233366ff%3B%22%3E%3CSTRONG%3ESolution%20%3A%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%22%3EYou%20need%20to%20enable%20the%20floating%20support%20by%20modifying%20some%20preprocessor%20directives%20in%20%22Defined%20symbols%20(-D)%22%20wizard%20of%20your%20project.%20Path%20%3A%26nbsp%3B%20Your%20Project%20%26gt%3B%20properties%20%26gt%3B%20C%2FC%2B%2B%20Build%20%26gt%3B%20Setiings%20%26gt%3B%20Tool%20Settings%20%26gt%3B%20MCU%20C%20Compiler%20%26gt%3B%20Preprocessor.%20These%20are%3A%3C%2FSPAN%3E%3C%2FP%3E%3CUL%3E%3CLI%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%22%3EPRINTF_FLOAT_ENABLE%20-%20keep%20the%20directive%20value%20to%20%3CSPAN%20style%3D%22color%3A%20%233366ff%3B%22%3E%221%22%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%22%3ESCANF_FLOAT_ENABLE%20-%20keep%20the%20directive%20value%20to%20%3CSPAN%20style%3D%22color%3A%20%233366ff%3B%22%3E%221%22%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%22%3ECR_INTEGER_PRINTF%20-%20Undefine%2FRemove%20this%20directive%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%22%3EClick%20on%20Apply%20and%20close.%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSPAN%20style%3D%22color%3A%20%23333333%3B%22%3EThat%20is%20it.%20Now%20you%20will%20have%20your%20expected%20prints%20for%20floating%20point%20values%20in%20your%20debugger%20console.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
100% helpful (2/2)
Version history
Last update:
‎02-19-2019 06:34 AM
Updated by: