Code Generation for Model that References an Export Function Model
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am having an issue using Embedded Coder to generate code for a model that itself has a reference to an export function model. I am able to open the referenced model independently and build code for it. Here's the setup:
Both models store their configurations in .mat files so they can be loaded into the base workspace, and the models themselves use Configuration References to the base workspace.
Export Model: A Simulink model for control and monitor of an LTC6804 chip. SPI data is fed into it and output from it without actually making direct hardware calls; that is left to the parent model to implement. A project file is set up that runs the .mat configuration file on startup so the configuration exists in the base workspace.
- "Hardware board" for this is set to "None" so it compiles generic code that can be ported to any target.
- "Code interface packaging" is set to "Reusable function" since more than one could be on any given target
- "Total number of instances allowed per top model" is "Multiple" for the same reason.
Parent Model: A Simulink model for monitor and control for a custom target. It also uses a project file. The folders where the model above is stored are added to the project path, but the referenced model's project is NOT a referenced project by the parent project. Rather, the parent model's project file manually loads both the referenced .mat configuration as well as its own, then modifies the referenced configuration to use the same "Hardware board" as the parent model. This allows the parent to implement the referenced export function for code generation without violating the Configuration Parameter requirements laid out in this article: Set Configuration Parameters for Code Generation of Model Hierarchies.
- "Hardware board" is the custom board we have generated for the custom hardware we are making
- "Code interface packaging" is set to "Nonreusable function" because one instance will run on the microcontroller
- "Total number of instances allowed per top model" is "One" for the same reason.
Even though I can Update the model, effectively building it for simulation, I get an error when I attempt to generate code. The error is as follows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1444842/image.jpeg)
So it seems like the recommended actions are to change the parent model's settings to...what they already are. I have even tried changing the child model's "Code interface packaging" to "Nonreusable function", and it did not change this error in any way. I have spent days trying to figure this one out, and I'm fully at a loss. If anyone has any idea what I might be doing wrong, I'd love to get this resolved.
2 comentarios
Zama Alex
el 6 de Feb. de 2024
Hello Dana Schwanke
I have exactly the same problem when try to generate C code from a multi-instance model that contain reference models. Did you solve the problem?
Thank you in advance.
Respuestas (1)
Debadipto
el 11 de Ag. de 2023
I understand that you are encountering an issue with Embedded Coder when generating code for a model that has a reference to an export function model. Despite having the correct settings in both the parent and referenced models, you are still getting an error during code generation.
Given the complexity of your setup and the efforts you have already made, it would be beneficial to reach out to MathWorks Technical Support for further assistance. Contacting MathWorks Technical Support will ensure that you receive the most accurate and up-to-date guidance to resolve this issue effectively.
0 comentarios
Ver también
Categorías
Más información sobre Simulink Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!