Other Parts Discussed in Thread: C2000WARE
Tool/software: TI C/C++ Compiler
Hi,
i am trying to make my C code faster. So i tried to write a function in assembler which calculates the manipulated variable of my control unit. I also calculated it with c code and compared the time of the calculation with an oscilloscope. Actually i thougt that assembler code is faster than C code, but in my case the C code was faster.
First of all, why does the compiler change the assmebler code that i wrote in my function? ( i viewed it in the disassembly style)
Secondly, is there a possibility to make the C code still faster by change the settings of the compiler or anything like that?
Does every line in the disassembly style take 1 cycle of the SYSCLK e.g. SYSCLK = 200MHz ( = 5 ns) than 10 lines of assembler code take 50 ns ? ( Is there a way to view how long a calucation needs?)
Which options do i have to get my code faster?
This is the code i compared:
C Code:
// only definitions , not part of the comparision float uk_1 = 1.1; float e_k = 2.2; float e_k1=3.3; float e_k2=4.4; float q0=5.5; float q1=6.6; float q2=7.7; float test_asm; // compared code test_asm = uk_1 +e_k*q0+e_k1*q1+e_k2*q3;
This is the assmebler code
// still in c extern float asmfunc_Regler_PID_1(float uk, float e_k, float e_k1, float e_k2, float q0, float q1, float q2 );
// compared part test_asm = asmfunc_Regler_PID_1(1.1,2.2,3.3,4.4,5.5,6.6,7.7); .global _asmfunc_Regler_PID_1 _asmfunc_Regler_PID_1: MOV32 R5H, *-SP[4]; liest float wert aus Stack MPYF32 R5H,R1H,R5H; q0*ek
MOV32 R6H, *-SP[6]; liest vorletzen übergabewert aus stack MPYF32 R6H,R6H,R2H; q1*ek1 ADDF32 R5H, R5H, R0H; uk1 + q0*ek parallel add MOV32 R7H, *-SP[8]; liest vorletzen übergabewert aus stack MPYF32 R7H,R7H,R3H; q2*ek2 ADDF32 R6H, R6H, R5H; (uk1 + q0*ek) + q1*ek1 NOP ADDF32 R0H, R7H, R6H; ((uk1 + q0*ek) + q1*ek1) + q2*ek2 | R0H ist der Rückgabewert LRETR
My compiler settings are:
-v28 -ml -mt --float_support=fpu32 --cla_support=cla1 --vcu_support=vcu2 --tmu_support=tmu0
--opt_for_speed=2 --include_path="C:/Bugy/ti/ccsv6/tools/compiler/ti-cgt-c2000_15.12.4.LTS/include" --
include_path="C:/Bugy/ti/xdctools_3_32_01_22_core/packages" --include_path="C:/Bugy/ti/controlSUITE/powerSUITE/v_1_06_00_00/packages" --
include_path="C:/Bugy/ti/controlSUITE/libs/app_libs/digital_power/f28x7x_v1.0/C_macros" --
include_path="C:/Bugy/ti/controlSUITE/libs/app_libs/digital_power/f28x7x_v1.0/include" --
include_path="C:/Bugy/ti/controlSUITE/libs/app_libs/SFRA/v1_10_00_00/Float/include" --
include_path="C:/Bugy/ti/controlSUITE/libs/math/IQmath/v160/include" --
include_path="C:/Bugy/ti/controlSUITE/device_support/F2837xS/v130/F2837xS_headers/include" --
include_path="C:/Bugy/ti/controlSUITE/device_support/F2837xS/v130/F2837xS_common/include" --
advice:performance=all -g --define=CPU1 --define=ARM_MATH_CM4 --define=_LAUNCHXL_F28377S --display_error_number --diag_warning=225 -k --asm_listing
