While generating C code, encountered with an error from ParameterWriter

11 vues (au cours des 30 derniers jours)
Rajesh
Rajesh le 25 Avr 2025
Modifié(e) : Anay le 28 Avr 2025
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?

Réponses (1)

Anay
Anay le 28 Avr 2025
Modifié(e) : Anay le 28 Avr 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!

Catégories

En savoir plus sur Deployment, Integration, and Supported Hardware dans Help Center et File Exchange

Produits


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by