Why does TI C2000 with CLA crash with the generated code for mod blocks
3 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2021-11-24
回答: MathWorks Support Team
2021-11-24
I have mod blocks for int16 and single inputs in CLA subsystem. The generated codes for CLA on TI C2000 contains the functions, "div_s16_floor()" for int16 and "rt_modf_snf()" for single. The two functions are causing CLA to stop executing or executing incorrectly.
采纳的回答
MathWorks Support Team
2021-11-24
The mod block creates the functions, "div_s16_floor()" and "rt_modf_snf()", in model.c file. In general, CLA cannot access the function defined in a .c file. Currently, the mod block cannot be inside CLA due to the creation of two functions in the .c file.
CLA is a floating point processor unit where integer modulus operation is not supported.
For single modulus, you can make use of "CLAdiv()" function provided by TI and that is part of CLA math library function. This can be done in Simulink by using the following statement in a MATLAB function block:
function rem = fcn(num, den)
%#codegen
Quotient = int32(0);
if isequal(coder.target,'rtw')
Quotient = coder.ceval('CLAdiv',num,den);
rem = num - single(Quotient)*den;
else
rem = mod(num,den);
end
end
Note: CLAdiv will return the result of float type.
You can also refer to the example “c28035pmsmfoc_cla.slx” where a similar implementation of other CLA math library functions has been made. In the example, look inside the park transformation block in the following path c28035pmsmfoc_cla/FOC Algorithm/Torque Control Algorithm/Generating Space Vectors/Generating Raw Space Vectors/Park Transformation.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!