准确的计时处理 [英] Accurate timing handling

查看:60
本文介绍了准确的计时处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在设计一个系统,其中我的要求如下:

我有一个USB-UART芯片.我正在开发一个应用程序,该应用程序应首先设置UART芯片(为此提供了驱动程序的Api)的波特率.

我的问题是,在应用程序中,我必须发送25 +/- 1 ms的数据位,说0.然后1持续50 + -1毫秒.这样就可以以高低模式发送数据.

看到要考虑的因素是:一旦我们将波特率设置为100 bps.这意味着在10毫秒内发送了1位.

在C#中,是否有可能处理这样的计时问题.如果是,我如何设计更好的方法?

否则,使用其他语言的方式是什么?

I''m currently designing a system wherein my requirements are as folows:

I have a USB-UART chip. I ''m developing an apllication which shall initially set the baud rate of UART chip(Api provided with driver for that).

My problem is that in the application i have a scenario where i have to send bits of data say 0 for 25 +- 1 ms. Then 1 for another 50 +-1 ms. Such that it sends data in a high and low pattern.

See consideration to make are: Once we set a baud rate of say 100 bps. it would mean 1 bit is sent in 10 ms.

In C#, is it possible to handle such timing pricisions . if yes how can i design it better way?

Otherwise what are the ways in other language?

推荐答案

.NET是不确定的,GC可能会暂停您的应用程序以清除计时器应触发的时间.因此,使用.NET不适用于您的情况.

不管您使用哪种语言,Windows都会在50毫秒以下将其精确度降低,因为它不是实时的,因此会给您带来很多不确定的抖动.
.NET is nondeterministic, the GC might suspend your application to clean up when your timer should fire. So using .NET isn''t good in your case.

No matter what language you use you''ll be affected by the fact that Windows isn''t accurate below 50 ms as it aint real time so you''ll be presented with alot of nondeterministic jitter.


请阅读Luc的文章:计时器意外,以及如何避免意外" [ ^ ].
Please read Luc''s article: "Timer surprises, and how to avoid them"[^].


这篇关于准确的计时处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆