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.

CCS/TMS320F28379D: Slave Stack Code Mapping Objects Float

Part Number: TMS320F28379D


Tool/software: Code Composer Studio

Hi,

i have issue with working with floats. In slave stack code(SSC) i defined my objects to be float -> in SSC they have data type REAL with 32 bit.

It looks like the following:

So i have float variables and and a float array.

In Code Composer studio i edited the mapping like it is said in the documentations:

Also i edited the parameter pData to be a 32bit variable, so i can transfer the 32 bit float/ real variables.

Working with TwinCat in Free Run mode i don´t get the right values for the float variables.

In Twincat i set the value to 3,0 so this result in hex 0x40400000 :

In Code composer studio i get something different. Here is it now in hex 0x4E808000 :

Is there something i must consider? Is it even possible to transfer float values?

With best regards,

Willi Konrad

  • Willi,

    I haven't tried datatype REAL32 but it should be possible, over the network and in the SM buffers it can be treated as 32 bits. You should be able to move 32 bits from ESC memory to MCU RAM and then typecast or treat the moved 32 bits as float and re-use as needed.

    Now, once you confirm the size of inputs and size of outputs is correct number of units of data, see if the function PDO_OutputMapping is moving all the bytes correctly into the MCU RAM from ESC RAM. You already know the plain bytes that should be seen in the MCU memory. See if you can put a break point in PDO_OutputMapping after the block read from ESC and inspect the MCU RAM for all bytes to be present.

    If not all bytes are coming in correct, then there is something wrong in the input/ouput objects definitions in the SSC tool and the Application object SW generated. I suspect that this will not be the case, but it is good to check.

    If you confirm that all the bytes are available in MCU memory after PDO_OutputMapping does the block read, then it is a matter of moving the data to the application variables like Laser_Angle. pData access is just moving data from MCU memory array to PDI_OutputMapping, see if having pData as 16 bit pointer makes any difference, see if the start of pData is shifted or does that seem right?

    Hope this helps.

    Best Regards
    Santosh Athuru
  • Hi Santosh,

    thanks for reply. I checked as you said. The data is moving correctly to the MCU RAM from ESC RAM. I see the correct bytes in the address where pData is pointing.

    But when assigning pData to my float variable it shows something different. I guess its because the compiler treat the value in pData as a decimal value and convert it to float. So here i´m confused, becuase it should be an integer but is treated as decimal.

    Here my example:

    I write to my variable the value 0.12345 -> in hex 0x3dfcd35b

    In my MCU RAM i see the same, so this works fine.

    But when assigning the value to my variable in CCS it looks different:

    You can see that my decimal value from Twincat (see picture above again -> dec: 1039979355) was converted to float, so it this gives the hex value 0x4E77F34D.

    Do you have an idea how to solve this?

    With best regards,

    Willi Konrad

  • Willi,
    I will cross check this with team here as well, in your APPL_OUTPUTMAPPING function, where you move the data from ESC RAM (pDATA pointer access) to output structure variable ANG_1, can you assign 16 bits at a time from pData to the ANG_1 instead of a 32 bit move?

    If you have the proper hex value in ANG_1 var then you should see the correct float right?

    Edit :- I cross checked with my team here, if you copy the 16 bits from pData to ANG_1 variable address instead of a 32 bit assignment from right to left you should see proper float value. Let us know if this works.



    Best Regards
    Santosh Athuru

  • Hi Santosh,

    thank you for cross checking. I tried with transferring only 16bits but it doesn´t work neither. It also converts my dec value to float, not the integer value. Its the same behaviour.

    Meanwhile i solved the problem. The solution is to memcpy the pData pointer to the variable

    I still don´t know why it won´t work with casting but this is a good workaround.

    Thank you for supporting

    Best regards

    Willi Konrad

  • Willi,

    yeah memcpy would work. Thanks for confirming, I was assuming the 16 bit moves would work as well as memcpy on C28 essentially moves 16 bits at a time, but looks like with 16 bit moves there is automatic type casting happening.

    memcpy with sizeof() is the better solution like you pointed.

    Best Regards

    Santosh Athuru