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.

TMS320F28027: Number conversion and operating cycle issue

Part Number: TMS320F28027
Other Parts Discussed in Thread: C2000WARE

Hi team,

Here're few questions from the customer may need your help:

1) Multiplication is required in the program, but the result of the multiplication is beyond the range of the original variable. How to convert it? 

volatile uint16_t inv_VbusInst;
volatile uint16_t inv_VbusAvg;

Above are the two variables in the structure Inv_var. 

if(inv_var.inv_VbusInst>15){
inv_var.inv_VbusAvg =(uint16_t)( ( ( (uint32_t)inv_var.inv_VbusInst-10 ) *62 ) >>8);

}

The calculated statements are as follows: 

inv_var.inv_VbusAvg=(inv_var.inv_VbusInst-10 )*62>>8;

When inv_var.inv_VbusInst=2000, the (inv_var.inv_VbusInst-10 )*6 result is greater than the maximum value of uint16_t data of 65536. Is the result of the multiplication automatically of the UINT16_t type, or is it left unchanged? 

2) (UINT32_t)inv_var.inv_VbusInst

Because inv_var.inv_VbusInst was the UINT16_t type. How many instruction cycles does this take in the calculation? 

3) During debug it's found the number of breakpoints cannot exceed two. Is it possible to set multiple breakpoints? Is there a runtime hint in debug? (the customer want to see when the code executes from one location to another) 

4) What are the _IQmpy(a,B), IQsin(a), _IQ(float F) instruction cycles respectively for IQ? 

Could you help check this case? Thanks.

Best Regards,

Cherry

  • Hi,

    inv_var.inv_VbusAvg =(uint16_t)( ( ( (uint32_t)inv_var.inv_VbusInst-10 ) *62 ) >>8);

    Can you declare VbusAvg as uint32_t? The result of the multiplication is 32 bit and the value is truncated when you typecast to uint16. 

    Because inv_var.inv_VbusInst was the UINT16_t type. How many instruction cycles does this take in the calculation? 

    Please refer to the C200 instruction set and C2000 Extended instruction Set documents. You can look at the code disassembly and cross check with the documentation to verify the clock cycles. Alternatively, you can use the CCS clock (Run -> Clock) to check the number of clock cycles. 

    During debug it's found the number of breakpoints cannot exceed two. Is it possible to set multiple breakpoints? Is there a runtime hint in debug? (the customer want to see when the code executes from one location to another) 

    C2000 only enables 2 breakpoints for debug. For runtime hint,  I will assign a CCS expert for this. 

    4) What are the _IQmpy(a,B), IQsin(a), _IQ(float F) instruction cycles respectively for IQ? 

    Please consult the documentation in c2000ware IQMath library: <c2000ware>/libraries/math/IQmath/c28/docs. 

    -Shantanu

  • Cherry,

    Regarding breakpoints,

    During debug it's found the number of breakpoints cannot exceed two. Is it possible to set multiple breakpoints? Is there a runtime hint in debug? (the customer want to see when the code executes from one location to another) 

    You can set unlimited number of software breakpoints. If the code is running from Flash, then you can use only hardware breakpoint and there is a limitation of only 2 hardware breakpoint supported on C28x devices. Please refer to link below which explains the details why we have the limitation.

    https://software-dl.ti.com/ccs/esd/documents/ccs_breakpoint_watchpoint_c2000.html

    On the newer devices, F28004x and newer, we have another IP called ERAD which extends the support for HardwareBreak point and brings more diagnostic and debug features.

    Thanks & Regards,

    Santosh

  • Hi Shantanu and Santosh,

    Thanks for your support! 

    a. VbusAvg is declared as UINT32_t, then is one or two instruction cycles for all the instruction cycles involving VbusAvg? The customer needs the procedure to be as fast as possible.

    b. Does IQ faster than a normal floating point number multiplied by an integer? 

    c. Are the 16-bit and 32-bit data types operating at the same speed when the shift left/right instruction is taken? 

    Thanks and regards,

    Cherry

  • Cherry,

    I am not sure if Shantanu had a chance to look at this. Please expect response by Monday.

    Thanks & Regards,

    Santosh

  • Cherry,

    a. VbusAvg is declared as UINT32_t, then is one or two instruction cycles for all the instruction cycles involving VbusAvg? The customer needs the procedure to be as fast as possible.

    This will vary with optimisation settings. The best way to check is to look at the assembly instructions in disassembly video and consult the CPU instruction set: https://www.ti.com/lit/ug/spru430f/spru430f.pdf?ts=1656317582355&ref_url=https%253A%252F%252Fwww.google.com%252F and extended instruction set: https://www.ti.com/lit/ug/spruhs1c/spruhs1c.pdf?ts=1656317609983&ref_url=https%253A%252F%252Fwww.google.com%252F manuals


    b. Does IQ faster than a normal floating point number multiplied by an integer? 

    To multiple two 32 floating point numbers, MPY32 takes about 3 pipeline cycles. IQNmpyI32 takes 4 cycles. Please consult the IQMath documentation for the cycle count. YOu can find the documentation in <c2000ware>\libraries\math\IQmath\c28\docs

    Are the 16-bit and 32-bit data types operating at the same speed when the shift left/right instruction is taken? 

    Yes. Again, please consult the above documents for exact cycle count details.

    -Shantanu

  • Hi Shantanu,

    Separate 10*IQtoF(_IQ(0.01)) and 10*0.01, which speed is fast? 

    Thanks and regards,

    Cherry

  • Cherry,

    10*0.01 will be faster as you don't have the IQMath conversion overhead.

    -Shantanu

  • Hi Shantanu,

    as you don't have the IQMath conversion overhead.

    As you said since 10*0.01 is faster, what's the purpose of IQMath operations and when to use IQmath? 

    Also, when the program is not debugged, is it possible to view the assembly code?

    Thanks and regards,

    Cherry

  • what's the purpose of IQMath operations and when to use IQmath? 

    If your program uses fixed point, IQMath is useful to do the operations in fixed point without having to convert to floating point and then use the FPU32. For example, some peripheral data output can be in fixed point.

    when the program is not debugged, is it possible to view the assembly code?

    YOu can use the dis2000 tool found in C:\ti\ccs1100\ccs\tools\compiler\ti-cgt-c2000_21.6.0.LTS\bin

    -Shantanu