This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CASTING : uint32_t to float (in code composer studio) ?

Other Parts Discussed in Thread: TM4C123GE6PM

hello i am having trouble casting uint32_t to float 

i have done a lot of basic C and casting has never been a problem

 
i tryed :

//file name :AdcTimerRead


uint32_t uint 1=10;

float value_TempConversion=0;

value_TempConversion = float(uint1/5.0); // this dosen t work gives the same errors

value_TempConversion = (float) uint1; // this dosen t work and gives me the following errors:

Description Resource Path Location Type
#10010 errors encountered during linking; "OxymetreDePouls.out" not built OxymetreDePouls C/C++ Problem

Description Resource Path Location Type
<a href="file:/c:/ti/ccsv6/tools/compiler/dmed/HTML/10234.html">#10234-D</a> unresolved symbols remain OxymetreDePouls C/C++ Problem

Description Resource Path Location Type
unresolved symbol value_TempConversion, first referenced in ./AdcTimerRead.obj OxymetreDePouls C/C++ Problem

i use the folowing includes in my code : 

#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/tm4c123ge6pm.h"
#include "driverlib/interrupt.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "driverlib/rom.h"
#include "driverlib/adc.h"
#include "grlib/grlib.h"
#include "grlib/widget.h"
#include "grlib/pushbutton.h"
#include "AfficherMenu.h"
#include "AdcTimerRead.h"
#include "arm_math.h"

maybe im missing an include i mean i feel like this is trivial dunno why im having soo much trouble.

  • nathan Yapi said:
    Description Resource Path Location Type
    unresolved symbol value_TempConversion, first referenced in ./AdcTimerRead.obj OxymetreDePouls C/C++ Problem

    This "first referenced" means that you have defined a C object twice or more, which is in violation of the C one definition rule. Possible also that you have a CCS setting that is causing this, like wrong path setting of to your Tivaware Installation. 

    So, this "first referenced" error might not be related to your casting problem.

    - kel

  • kel : 

    i think i understand what ur saying lol 
    but how to i find what object i ve defined twice .... 
    please take note that in my program i use a lot of grlib and driverlib fonction from tivaware

    and they work fine with no compilation errors ... untill i try using a cast 
    Dosen t this mean that the path to the tivaware librarie is the correct one ? 

  • nathan Yapi said:

    uint32_t uint 1=10;

    float value_TempConversion=0;

    value_TempConversion = float(uint1/5.0); // this dosen t work gives the same errors

    value_TempConversion = (float) uint1; // this dosen t work and gives me the following errors:

    Is the space between uint and 1 a mistake?

    - kel

  • yes that space in particular is a mistake from when i copyed it .. its not actually in my code 
    sorry for that :(

  • Hi Nathan,

         What is your optimization settings?

    - kel

  • waz up Kel,

    hmm msince i am using the CMSIS-DSP lib i had to follow the spma041c settings 
    which puts my optimazation settings at 2.

  • As you note this should be trivial so the first thing to do is reduce this to a single file with standard includes (No TIVAWare, no compiler specific headers).

    If you cannot make that work, and it should require not much more than a dozen lines, post that entire set of code (cut and paste, do not re-type).  It should then be relatively simple to find the problem.  Particularly with some other tools that are available.

    If the does work then take the original file and comment out the non-compiling section.  Once you have something that compiles then cut and paste the working casting into the now modified original.  You should now either have something that works or a simple set of changes to check to find what causes the failure.

    It's almost certainly something like a typo (such as confusing l and 1)

     

    Robert

     

    And don't forget to clean up after all of the exploration.

  • as u said it was trivial ... turns out i had declared the variable i wanted to cast to only in my header file as extern but not anywhere else soooo ya my bad :(

    thank you

  • We all do it once in a while, glad you found it.

    I will, once again, recommend PC-Lint.  It's good at catching things like this.  You do have to set it up to do whole project checking but it is good at that and it has it's own version of separate compilation that reduces the amount of checking needed when you only change a few modules.

     

    Robert