阅读:1663回复:7
关于用FX2中定时的问题(大侠快来忙帮啊)
我的要求为:
用CY7C68013片子,gpif控制方式,每20ms发一帧图像,20ms中还有可能有数据返上来。 我准备这样做:先向下传一帧图像,用下面的单片机做定时,用中断传输方式,通过主机不断查询该端点,假如到了20ms,再传输下一帧。 但是这样做就有了两个问题:1.下面的单片机什么时候启动定时? 2.上面的主机怎么不断的查询该端点,那岂不是死循环啊。 还有中断传输也要主机不断查询端点,下面是2.0的协议: For input interrupt endpoints, the host has no way to determine whether an endpoint will source an interrupt without accessing the endpoint and requesting an interrupt transfer.那用中断传输有什么好处,用块传输又有何不可。难道是中断速度快一点。 还有usb鼠标也是主机不断查询的吗? |
|
沙发#
发布于:2003-11-01 11:07
int和bulk的唯一区别就是,int是主机每隔一定的时间发送一次查询命令,而bulk是只有你有请求的时候才会发送查询指令。
usb鼠标用的是int传输,也就是说没过一段时间主机会发送查询指令看鼠标是否有动作。 2,是死循环,当然你需要设置跳出的条件,比如你按了停止按钮就停止传输什么的。 |
|
板凳#
发布于:2003-11-01 17:34
谢谢jinghuiren仁兄的回帖
只是对“int是主机每隔一定的时间发送一次查询命令”不太理解 是不是一次查询能保持一段时间 我觉得可能和协议中的这段话有关: An endpoint for an interrupt pipe specifies its desired bus access period. A full-speed endpoint can specify a desired period from 1 ms to 255 ms. Low-speed endpoints are limited to specifying only 10 ms to 255 ms. High-speed endpoints can specify a desired period (2bInterval-1)x125 µs, where bInterval is in the range 1 to (including) 16. The USB System Software will use this information during configuration to determine a period that can be sustained. The period provided by the system may be shorter than that desired by the device up to the shortest period defined by the USB (125 µs microframe or 1 ms frame). The client software and device can depend only on the fact that the host will ensure that the time duration between two transaction attempts with the endpoint will be no longer than the desired period. Note that errors on the bus can prevent an interrupt transaction from being successfully delivered over the bus and consequently exceed the desired period. Also, the endpoint is only polled when the software client has an IRP for an interrupt transfer pending. If the bus time for performing an interrupt transfer arrives and there is no IRP pending, the endpoint will not be given an opportunity to transfer data at that time. Once an IRP is available, its data will be transferred at the next allocated period. 只是看了以后还是不理解 望哪位大侠看看,给我讲一下这段话的意思 |
|
地板#
发布于:2003-11-01 20:21
ft!你想让我给你翻译协议呀!
如果你没看明白,那就算我给你翻译出来你也不一定能明白! 你的理解是不对的,据个例子来说:如果你有64KB的数据要传给设备,并且想通过一个INT端点来进行,这个INT端点Interval设定的是1ms,那么主机上的表现是每隔1ms发送一个out包,判断设备端点是否为满,如果为空,那么就把其后跟的数据写到端点里,否则就要等下一个1ms,直到把64k数据全部传给设备为止,此后主机就不会在查询了。 当然鼠标的和这有些区别,鼠标是在驱动里实现了连续的查询功能,也就是说只要你的主机是开着的,并且在使用鼠标,那么驱动程序就会每隔一定的时间去查询一下鼠标的状况,如果你的应用中需要这样做,也可以的,只要在驱动里实现就行了。因此一般情况下都选择使用bulk传输,它不是每隔一定的时间查询一次,而是只要有数据就连续不断的查询。 |
|
地下室#
发布于:2003-11-03 12:05
恕我比较愚笨。
你举的例子,我还有几个问题 1。主机是不是一直在执行中断写哪?还是只要我执行一次中断写它就会每隔1ms就会向下写?我觉得是第一种方式,也就是我认为主机是不断查询的,不管是中断读还是中断写。只有主机有查询时,1ms才会启动。 2。如果是那样的话,用中断做定时,就是只有单片机定时到20ms,我用主机查询该端点时,才会有中断读传输。那用块传输还不是一样啊,我可以在固件中封锁该端点,只有到20ms时才响应主机的查询。 本来我觉得用中断坐定时会比较好那。 |
|
5楼#
发布于:2003-11-03 13:43
不明白你为什么要用定时!
只要主机边有数据请求,那么驱动程序就会一直向设备发送读写令牌,不管是bulk还是int,如果设备边没有数据,主机边就不断查询。 只是这int和bulk的区别是:bulk会一直查,不间断,而int是每隔一段时间查一次,懂了吗 如果你的数据不是连续的,你根本就不需要做定时,固件里只要有数就往端点里写,没有数就等待,主机会等着你的数据的。 如果你的数据是现成的,只是想每隔20ms传一组给主机,那你固件里就每隔20ms写一组数到端点里不就完了?很复杂吗? |
|
6楼#
发布于:2003-11-04 23:32
谢谢jinghuiren兄的指教,等解决了问题好好谢谢你。
我是因为主机向设备传输的图像数据要和电视信号同步,而fx2的FIFO存储区又太小,所以只有每隔20ms发一帧图像拉 我觉得你说的\"int是每隔一段时间查一次\"不太对,应该是主机一直查询的,只是中断端点只有在到了设定的时间才响应主机查询的,不知对不对? 我得数据在主机里是连续的序列图像。 |
|
7楼#
发布于:2003-11-05 09:06
我和你的问题差不多,也是传图像数据和同步信号,只不过我是向pc方向传,我用ep2传图像,ep1传同步。我不太明白如果主机方向一只查询ep1的话,那图像数据怎么办?还是要两端点切换查询,可那样效率不是很低。
|
|