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.

In CCSv6, reading ADC (U16) registers into a float



I am using the F28377D processor with CCSv6 6.0.1.00040, and I am trying to use the CLA to read my ADC values, and I need to perform some floating point math on the ADC results -- within the CLA.

I can read the AdcxResultRegs.ADCRESULTx registers to a data-type of unsigned int and return them to CPU1 as unsigned ints. However if I read the AdcxResultRegs.ADCRESULTx registers to a float variable OR read the AdcxResultRegs.ADCRESULTx registers to a U16 and convert to a float, the resulting float is not the same integer value.

For example, reading the results from the CLA within the CPU debugger:

   CLA code:

   RawNeg5VMonCount2 = AdccResultRegs.ADCRESULT6;   //RawNeg5VMonCount2 is a U16
   ADCResults.D5VMon = RawNeg5VMonCount2; //ADCResults.D5VMon is a float

In CPU1:

RawNeg5VMonCount2 = 2279d

ADCResults.D5VMon = 1.507349E+08

I have tried various combinations of this, with and without casting. Also if I hard-code ADCResults.D5VMon = 2279 (in the CLA), it is returned correctly to CPU1, so I know the interface is OK.

Is this possible to do within the CLA? Do you have any suggestions?

Thanks,

Jim

  • The CLA compiler does support assignment between the types float and unsigned short.  I don't know anything about specific registers on CLA.  I've asked for some help on that.

    Thanks and regards,

    -George

  • Jim,

    You can assign the adc result to a 32-bit int and then the int to float conversion will work. The CLA does have an assembly instruction MI32TOF32 that does the cast in a single cycle.

  • I am writing this all in (CLA) C, if I did not mention it before. Reading the registers as a U32 did not help, but I did find a work-around which works with both U32 and float:

          RawNeg5VMonCountU32 = AdccResultRegs.ADCRESULT6 & 0xFFFF;

          RawNeg5VMonCountF32 = AdccResultRegs.ADCRESULT6 & 0xFFFF;

    Both the U32 and float read on the 16 bit register appears to read in as a U32, so the garbage upper 16 bits must be zero-ed.

    Thanks,

    Jim

  • Hi Jim

    After going over the available assembly instructions in the manual, the CLA does have instructions to do UI16 to F32 i.e. MUI16TOF32 which is what the C compile will use...so im not quite sure what happens with your code.

    It would be useful if you could post the disassembly for that portion of the code that gives you garbage values.