嵌入式数据结构

上传人:cn****1 文档编号:504079314 上传时间:2023-09-10 格式:DOCX 页数:7 大小:67.65KB
返回 下载 相关 举报
嵌入式数据结构_第1页
第1页 / 共7页
嵌入式数据结构_第2页
第2页 / 共7页
嵌入式数据结构_第3页
第3页 / 共7页
嵌入式数据结构_第4页
第4页 / 共7页
嵌入式数据结构_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《嵌入式数据结构》由会员分享,可在线阅读,更多相关《嵌入式数据结构(7页珍藏版)》请在金锄头文库上搜索。

1、程序的执行与嵌入式编码这一节主要描述的是主要数据结构的代码生成和嵌入式编码器实时车间。他也总结概括了 由文件和头文件构成的编码器实时车间嵌入式的程序,还有描述了怎么找到他们。另外,这一 节将描述如何生成实时嵌入式编码器车间项目,从最高水平下降到定时器中断水平。本章节包 含下列主题:(略)一:代码模块的数据结构实时模型数据结构实时嵌入式编码在车间实时模型数据结构中封装关于根模型的信息。我们把数据结构的实时 模型叫做运转计时器(简称rt m)。为了减少内存需求,rtm只包含响应你模型的信息。例如,相关领域的数据只有在拥有 MAT-file具有代码生成选项时启用。Rtm可能也包含有关时间,结算器,还

2、有模型数据的特殊模 型的rtM相关信息,例如:输入,输出,声明,参数。由于默认,rtM包含一个错误状态,在此时你的代码就可以监视或者设置。如果你不需要日志 或监控你的应用程序错误状态,就选择错误状态实时抑制模型数据结构的选项。这将进一步减少 内存使用。选择此选项,也可能导致rtM从生成的代码中完全消失。rtM符号的定义的生成代码如下:Structure definition (in model.h):struct _RT_MODEL_model_Tag ;Forward declaration typedef (in model_types.h): typedef struct _RT_MOD

3、EL_model_Tag RT_MODEL_model;Variable and pointer declarations (in model.c):RT_MODEL_model model_M_; RT_MODEL_model *model_M = &model_M_;Variable export declaration (in model.h):extern RT_MODEL_model *model_M;栈宏实时车间提供的嵌入式编码器栈宏,使你的代码能够与rtM界面有接口。通过model.h,你的 代码可以使用宏,并可以进入他们引用的任何字段。如果你的代码是连接到一个单一的模型,一般来

4、说,你应该把rtM指向model_M,使用宏来访问 model_M,就像下面的代码片断。#include model.hconst char *errStatus = rtMGetErrorStatus(model_M);你的代码与rt Ms的接口有多个,只需要把头文件对应于每个模型,就像下面的代码片断。 #include modelA.h /* Make model A entry poi nts visible */ #include modelB.h /* Make model B entry poi nts visible */ void myHandWrittenFunction(v

5、oid)const char_T *errStatus;modelA_initialize(1); /* Call model A initializer */ modelB_initialize(1); /* Call model B initializer */ /* Refer to model A s rtM */errStatus = rtmGetErrorStatus(modelA_M);/* Refer to model B s rtM */errStatus = rtmGetErrorStatus(modelB_M);表2-1总结了 rtM错误状态的语句。如果要查看其他适用于你

6、的模型的有关于宏的rtm和生成的 代码,那么利用代码生成报告(见“生成一个代码生成报告3 - 10页);然后在报告中通过超链接 查看 model.h。Tabl& 2-1|: rtM Error Stahjs MacrosMacroArgurnent(s)ReturnTyPeDescripHonrtnGetErrarStatds(rtm)rtm: reference to real-time model structchar *Returns most recent error status string.rtmSet ErrorStatus(rtm,val)rtm: reference to

7、real-time model structval: C stringN/ASet error status field of real-time model struct to the string val.数据结构本节概述了头文件和代码模块是如何构成实时车间嵌入式编码程序的,并叙述了到哪儿能找 到它们。注意:大多数情况下,最简单的方式找出并检查其生成的代码文件是使用嵌入式编码器实时 车间代码生成报告。这个代码生成报告提供了一个超链接表,让你查看生成的代码,在MATLAB 帮助浏览器。看“生成一个代码生成报告“的3至10页,以获得更多的资讯生成的代码模块在您的工作目录,嵌入式编码器实时车间创

8、建一个目录用来存储生成的源代码。建立目录也 包含对象文件,一个基本程序结构以及实用编译方法,和其他文件过程中产生的代码生成的过 程。默认名称的目录是model_er t_r tw。表2 - 2总结了结构的源代码由嵌入式编码器实时车间生成Table 2-2: Real-Time Workshop Embedded Coder File PackagingFileDescriptionmodel. cContains entrjr points for all code implementing the model algorithm(mode2_step5 mode I _iin i t ial

9、 iz e ;,(nodel_t e r mi n a t et tnodel _Set Events Fo rT hisBaseStep).mode2_privatea h Contains local macros and local data that are required by the model and subsystems. This file is included by the generated source files in the model. You do not need to include model_private h when interfacing ha

10、nd-written code to a model.model hDeclares model data structures and a public interface to the model entrypoints and data structures. Also provides an interface to the real-time model data 吕tructurEvia accessor macros, model h isincluded by subsystem . c files in the modeLIf you are interfacing your

11、 hand-written code to generated code for one or more models, you should include model h for each model to which you want to interface.mode2_data cmotfel_data. c is conditionally generated. It contains the declarations for(conditional)the parameters data structure and the constant block I/O data stru

12、cture.If these data structures are not used in the model, model_data is not generated. Note that these structures are declared exte口 in model h.mode2_types hProvides forward declarations for the real-time model data structure andthe parameters data structure. These may be needed by function declarat

13、ions of reusable fLinctions. moofel _types h is included by all the generated header files in the model.User-Written代码模块你写的代码生成的模型与接口代码通常包括一个定制的主要模块(基于主程序提供嵌入式 编码器实时车间),可能还包括中断处理程序,设备驱动模块和其他S-functions,和其他管理或 支持代码。我们建议你为你自己的代码模块建立一个工作目录。你的工作目录应该在MATLAB的路径。 你也必须修改实时嵌入式编码模板基本程序结构以及实用编译方法和车间系统目标文件,使得 建

14、设进程可以找到你的源和目标文件。生成主程序产生一个例子主程序选择控制是否需要ert_main.c生成。这个选项位于插入代码生成的选 择(3)范畴的实时车间方格仿真参数对话框,如下图。默认情况下,会产生一个例子主程序。当生成一个例子主程序被选中时,这个目标的弹出式 菜单操作系统被激活。这个菜单让您选择下列选项:1 BareBoardExample:产生一个bare-board主程序设计控制下运行的实时时钟,不包含实时 操作系统。2 VxWorksExample:产生一个完整的注释的例子用来显示如何在VxWorks实时操作系统部署 代码。不管你选择哪些目标操作系统ert_main.c都包括:1主函

15、数2任务调度的代码块,决定如何及何时执行每次计算步骤的模型主程序的运行和调度算法主要取决于雇佣你的模型是否单频或者多频,也取决于你的模型 的求解模式(SingleTasking与多任务)。这些在“程序执行” 2-9页中有详细地描述。程序的执行接下来的章节描述程序所产生的实时嵌入式编码器车间的执行,从最高水平下降到定时器中 断等级单独的程序执行默认情况下,实时车间嵌入式编码程序自动生成程序而不需要外部实时执行的或者操作的系 统。我们称这种程序作为独立的程序。一个单独的程序需要一些最小可改性来适应目标硬件; 这些修改,随后的章节描述。单独的程序支持单个或多个样本率。生成一个单独的程序:1在ert代码生成的选择(3)类标签的实时车间仿真参数对话框中,选择产生的主要程序实例 的选择(这个选项是默认的情况下的选择)。2当生成一个例子主程序被选中,这个目标的弹出式菜单操作系统被激活。从这个菜单选择 BareBoardExample(这个选项默认选择)。一个单独的程序的核心是主要的循环。在每步迭代计算中,主循环执行一个背景或空的任务 和检查终止条件。主循环周期性的被计时器打断。实时车间功能rt _OneS tep要么是安装一个定时器中断服务程 序(ISR),那么在每个步骤调用一个定时器ISR。rt _OneS tep在执行时候顺序调用model_s tep功能

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号