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.

TMS320F28P559SJ-Q1: discussion on the calculation bit width.

Part Number: TMS320F28P559SJ-Q1


Tool/software:

Hi Expert

Customer is the new user of C2000 devices, they see some output during the test and want to discuss below:

1. in the operation: Dvb = (uint32_t)((level-1)*(0x7FF-0x0c)), the Dvb type is uint32, level type is uint32, the expect output is 0x0007E31A, but the real output is 0x0000E31A, the number 7 is ignored due to overflow. the question is why no matter level type is uint32 or uint16. the return value of the operation (level-1)*(0x7FF-0x0c) always looks like a uint16 result?

2. in the operation (uint32_t)pData[3]<<24 | pData[2]<<16 | pData[1]<<8 | pData[0];, the final return value is a uint16 type, which result in the lost of pData[3] and pData[2]. the pData is a uint_8 array. How CPU handle this operation in register?

Thanks

Joe

  • Hi Joe,

    1. Can you try to type cast the numbers to uint32 or use a 32-bit hex representation. It may be that the subtraction results in a uint16 values. Let me know if that works.

    2. i believe you will need to typecast each call to pData to treat it as 32-bit value before you start shifting bits.

    Let me know if these work for you.

    Regards,

    Ozino

  • Hi Ozino

    Thanks will try your suggestion once I can get a Launchpad, one more thing I want to discuss is, is there the documents to summarize the operation roles of CPU calculation, for example:

    if variable "level" is uint32 type and constant "1" is seen as uint16 fix point, then the result of "level-1" will keep uint32 type or treaded as uint16 if the upper 4 bytes are 0 or if the the upper 4 bytes are not 0.

    For the bits shifting operation, if the data type is uint8 (seen as uint16 in C28), the left shift 24-bit, will the data ignored due to overflow, or will the data type of Intermediate variables is 32-bit width and keep all the value?

    Thanks

    Joe

  • Please look at the following documentit has the CPU instruction set and can provide more details.

    https://www.ti.com/lit/ug/spru430f/spru430f.pdf