Effacer les filtres
Effacer les filtres

Simulink defines uint16 as uint32.

38 vues (au cours des 30 derniers jours)
Onno Twisk
Onno Twisk le 10 Juil 2024 à 9:48
Commenté : Onno Twisk le 10 Juil 2024 à 10:17
Hi everybody!
I'm buidling a model to use with the c2000 f28379D launchpad. To optimise a couple of processis I wanted to use c-code. Things were going well but now i am getting errors that I frankly don't really understand:
I'm using uint16_T in my code but it seems that Simulink has redefined that to uint32_T, and then gets confused when the pin type is uint16 in Simulink. I don't know why it's doing this as the launchpad has 16 bit characters and I've configured that correctly (I think). What is going on here? I have the same issues with both my r2024a and r2023b installation. Thanks in advance!
Included are all the relevant files, a version for r2024a and one I created for r2021b which gives me the same error

Réponses (1)

surya venu
surya venu le 10 Juil 2024 à 10:06
Modifié(e) : surya venu le 10 Juil 2024 à 10:08
Hi,
The error you're encountering suggests that there is a mismatch between the data types defined in your custom C code and the data types expected by Simulink. Specifically, it seems that Simulink is expecting "uint32_T" while your C code is using "uint16_T".
Check Data Type Definitions: Ensure that the data types are consistently defined across your C code and Simulink model. In your C code, you might have something like:
typedef unsigned short uint16_T;
typedef unsigned int uint32_T;
I see that in "rtwtypes.h" file you've shared, "uint16_T" is defined as "int". But ideally it should be "short".
Hope it helps.
  1 commentaire
Onno Twisk
Onno Twisk le 10 Juil 2024 à 10:17
Hi Surya,
Thanks for getting back to me so quickly. rtwtypes.h is normally generated when building a project for C2000, so to make sure things are compatible with that I wanted to use it for this example. Selecting the right launchpad gives me this window where you can see that the integer uses 16 bits:
I'd rather not use different definitions than what is in rtwtypes as I'm afraid that will cause different issues down the line.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by