Main Content

异步任务的计时器

ISR可以设置绝对时间的来源。这是通过功能完成的ssSetTimeSource。功能ssSetTimeSource以前无法打电话sssetOutputPortWidth叫做。如果发生这种情况,该程序将停止并生成错误消息。ssSetTimeSourcehas the following three options:

  • ss_timesource_self:每个生成的ISR都保持其自己的绝对时间计数器,该计数与系统中的定期基本率或子量计数器不同。计数器值和计时器分辨率值(用块参数指定Timer resolution (seconds)of theAsync Interrupt下游块使用块)来确定块计算所需的绝对时间值。

  • ss_timesource_caller:ISR从其呼叫者维护的计数器中读取时间。因此,时间分辨率与呼叫者的分辨率相同。

  • ss_timesource_baserate:ISR可以从模型的周期性基本率中读取绝对时间。因此,时间分辨率与其基本利率分辨率相同。

笔记

本节中证明的操作系统集成技术使用一个或多个封锁在VXLIB1图书馆。这些块提供了起点示例,以帮助您为目标环境开发自定义块。

默认情况下,counter is implemented as a 32-bit unsigned integer member of the定时实时模型结构的子结构。对于支持金宝apprtmodel数据结构,当未使用时间数据类型时SsetAsynctimeDatate,反词大小由模型配置参数的设置确定申请寿命(天)。例如(来自ERT目标代码),

/ *实时模型数据结构 */ struct _rt_model_elapsetime_exp_tag {const char *errorStatus;/ * *定时:​​ *以下子结构包含有关模型的定时信息的信息。*/ struct {uint32_t clocktick1;uint32_t clocktick2;}定时;};

该示例省略了未使用的字段定时数据结构(在GRT中找不到ERT目标代码的功能)。对于支持金宝apprtmodel数据结构,计数器大小由模型配置参数的设置确定申请寿命(天)

默认情况下,VXLIB1示例rtos的库块(vxworks®)将计时器源设置为ss_timesource_self并使用系统调用更新其计数器tickgettickgetreturns a timer value maintained by the RTOS kernel. The maximum word size for the timer isUINT32。以下示例显示了生成的调用tickget

/* vxworks中断块:'/async中断'*/void isr_num2_vec193(void){/*使用tickget()作为便携式tick counter示例。使用硬件计数器 */ rtm-> timing.clocktick2 = tickget();。。。

tickget调用提供的只是一个例子。它可以(我n many instances should) be replaced by a timing source that has better resolution. If you are implementing a custom asynchronous block for an RTOS other than the example RTOS (VxWorks), you should either generate an equivalent call to the target RTOS, or generate code to read a timer register on the target hardware.

更改块参数的设置Timer resolution (seconds)为您Async Interrupt块以匹配目标计算机的定时源的分辨率。

这counter is updated at interrupt level. Its value represents the tick value of the timing source at the most recent execution of the ISR. The rate of this timing source is unrelated to sample rates in the model. In fact, typically it is faster than the model's base rate. Select the timer source and set its rate and resolution based on the expected rate of interrupts to be serviced by theAsync Interrupt堵塞。

For an example of timer code generation, seeAsync Interrupt Block Implementation

相关示例

更多关于