MATLAB: Is the sample time incorrect in the generated code for a subsystem in the Real-Time Workshop 5.0 (R13)

codefixed-stepgenerations-functionsamplesimulink codersize;subsystemtime

I have model with fixed step solver and a specified fixed step size 0.00065. When I generate an S-function for a subsystem in the model, I received the following error message:
Invalid setting for fixed-step size (0.00065) in model 'model_name'. All sample times in your model must be an integer multiple of the fixed-step size.
When I look at the generated code subsystem_sf.c, I found that the sample time is set as the following:
/* task periods */
ssSetSampleTime(S, 0, 0.0);
ssSetSampleTime(S, 1, 0.4);
This is incorrect. The second sample time should be 0.00065 as I specified in the model Simulation Parameters Solver panel.
When I try to build this subsystem, in the generated code subsystem.rtw I found in the structure FixedStepOpts, the FixedStep is also set incorrectly.
Both cases are not a problem in the Real-Time Workshop 4.1.1 (R12.1). The incorrect code of sample time only happens since Real-Time Workshop 5.0 (R13).

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This is a bug in Real-Time Workshop 5.0 (R13). As a workaround, explicitly specify the sample time in the Inport block under the subsystem.