Is there a bug with code generation for C2000 device? (R2013b)
2 次查看(过去 30 天)
显示 更早的评论
Hi,
Here is my problem:
Is use Embedded Coder to generate code for C2000 from a Simulink project.
I noticed that one of my S-functions create a memcpy() C function. The generated code is the following:
/*
* Output and update for atomic system:
* '<S1>/MATLAB Function'
* '<S1>/MATLAB Function2'
*/
void test_gup35_MATLABFunction(real32_T rtu_u, B_MATLABFunction_test_gup35_T
*localB)
{
uint32_T y;
/* MATLAB Function 'Fct_algo_2kHz/MATLAB Function': '<S8>:1' */
/* '<S8>:1:4' */
memcpy(&y, &rtu_u, 4UL);
localB->y = y;
}
S-function .m
I tested the code with Code Composer Studio in debugger mode. The 4UL memcpy() argument is not correct. On C2000 sizeof(uint32_T) returns 2, not 4! So the result is a wrong execution of the software due to the to large copy. If I change the line memcpy(&y, &rtu_u, 4UL); by memcpy(&y, &rtu_u, sizeof(y)); it works.
Is there a parameter in Simulink to change the argument size? Or is it a bug from Embedded Coder?
Thanks, Dimitri
0 个评论
回答(1 个)
Ketan
2015-9-15
This is a known issue. Please see the following EBR for a workaround:
https://www.mathworks.com/support/bugreports/1034916
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!