필터 지우기
필터 지우기

how to use extern variable from custom C code in stateflow ?

조회 수: 9 (최근 30일)
RK
RK 2023년 5월 26일
답변: Meet 2023년 5월 29일
I have a statemachine in stateflow and embedded c code. I am importing this external c code by defining its header file and directory in simulation target and code egenration setting. after completing this, I am able to call the functions which are defined in those header files but I am not able to use the variables which are declard as extern. Stateflow is prompting to declaring that variable in symbols pane. does anyone have solution for this ?

답변 (1개)

Meet
Meet 2023년 5월 29일
Hi RK,
To solve this issue, you need to declare the external variables in the 'Symbol management' section as these variables are not part of the Stateflow model. Follow the below steps to do that:
  1. Open the Stateflow editor and select the chart that requires the external variable.
  2. Click on the 'Chart' tab in the Properties pane.
  3. You will find the 'Symbols pane' below that.
  4. Click on 'Add' and select 'Data'.
  5. Define the data type and name of the variable that you want to use in Stateflow.
  6. In the value section select 'external', and in the C identifier textbox, write the exact name of the variable defined as extern in your code.
  7. Save and close the editor.
This will declare the external variable in the Stateflow model, and you should be able to use it in your Stateflow chart without any issues.

카테고리

Help CenterFile Exchange에서 Embedded Coder에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by