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.

FPU floating point unit usage

Other Parts Discussed in Thread: MOTORWARE

In motorware, some of the labs use the FPU.

proj_lab04a uses the FPU, where proj_lab04 doesn't. The difference I see is that in lab4a EST_ call return values are assigned to a tmp variable, where in lab04, EST_ call return values are assigned directly to the gMotorVar.

And in in proj_lab04a, there is a comment that says:

// when calling EST_ functions that return a float, and fpu32 is enabled, an integer is needed as a return
// so that the compiler reads the returned value from the accumulator instead of fpu32 registers

Seems like the comment is saying that the FPU is not used in lab_04a.

 Where in the code is it specified that the FPU is to be used?

Thanks in advance!

Charlie

  • the library in ROM does NOT use the FPU under any circumstances. When you run an "FPU" lab, you are using the FPU only for non-ROM functions. The tmp variable thing is required when using variables from the fixed point library.

    " // when calling EST_ functions that return a float, and fpu32 is enabled, an integer is needed as a return
    // so that the compiler reads the returned value from the accumulator instead of fpu32 registers"

    the linked resources in the .project file (or in your CCS project view) is what tells the project you are using FPU
    <link>
    <name>2806xRevB_FastSpinROMSymbols_fpu32.lib</name>
    <type>1</type>
    <locationURI>MW_INSTALL_DIR/sw/modules/fast/lib/32b/f28x/f2806x/2806xRevB_FastSpinROMSymbols_fpu32.lib</locationURI>
    </link>
    <link>
    <name>F28069F_ram_lnk.cmd</name>
    <type>1</type>
    <locationURI>MW_INSTALL_DIR/sw/ide/ccs/cmd/f2806x/F28069F_ram_lnk.cmd</locationURI>
    </link>
    <link>
    <name>IQmath_fpu32.lib</name>
    <type>1</type>
    <locationURI>MW_INSTALL_DIR/sw/modules/iqmath/lib/f28x/float/IQmath_fpu32.lib</locationURI>
    </link>
  • I see that in the .project file for the projects that state they use the fpu. And in CCS I see that fpu32 is selected in project properties.

    Regarding the tmp var, how is the fixed point library related to the fpu? I only see that tmp assignment in labs when the fpu is used.
  • the fixed point motor control library (in ROM) is not related to the FPU at all. We used a common code base to create a library that can run on F2806x, 5x, and 2x series of devices. Only the 6x has an FPU. So, when you don't use the FPU on the 6x everything behaves the same. When you do use the FPU on the 6x, the compiler wants to read floating point variable values from the FPU registers so we have to "trick" it so that it reads the values from the accumulator. It's just a code work around to have floating point values from a fixed point library.