While generating C code, encountered with an error from ParameterWriter

4 views (last 30 days)
The error is
parameter Writer block is unable to write to parameter 'PulseWidth' of block 'Discrete Pulse Generator', because the corresponding dialog parameter and run-time parameter do not have a one to one mapping.
Can anyone help with the above error?

Answers (1)

Anay
Anay on 28 Apr 2025
Edited: Anay on 28 Apr 2025
Hi Rajesh,
I understand that you are working with a model which has a Parameter Writer block and Discrete Pulse Generator block as primary blocks where you want the Parameter Writer to write the “pulseWidth” parameter of the Discrete Pulse Generator block. I assume that the following model matches the workflow you are trying to achieve. I tried generating code for this simple model and it seems to work for me without any issues:
I would encourage you to include implementation details such as screenshots of your model or include the model files if you can in the question. I found that to generate code from above model using embedded coder you have to set the “Default Parameter Behaviour” in the model settings to “Tunable”.
Also, ensure that you have defined the variables which will be used as values for your model parameters in the Base Workspace or Model Workspace:
PulseWidthVar = Simulink.Parameter(5);
PulseWidthVar.StorageClass = 'ExportedGlobal';
Making PulseWidthVar's storage class as 'ExportedGlobal' will tell Simulink to have it as a globally defined variabled in the generated code.
Hope this resolves the issue!

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!