Is there a bug with code generation for C2000 device? (R2013b)
    7 views (last 30 days)
  
       Show older comments
    
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 Comments
Answers (1)
  Ketan
    
 on 15 Sep 2015
        This is a known issue. Please see the following EBR for a workaround:
https://www.mathworks.com/support/bugreports/1034916
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
