完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
说我们需要使用ADC、USAT和USB等外围设备的应用程序。我不知道如何将它们合并到AppyTasks-()状态机中。例如,应用程序应该监视ADC、USAT和USB。当ADC中存在信号时,应该对其进行服务。此时,USB或USAT可能正在使用,或者可能没有被使用。无论USB或USAT的状态如何,都应该停止USB和USAT,并为ADC服务。如何将这种逻辑集成到状态机中?
以上来自于百度翻译 以下为原文 Say we need application that uses peripherals like ADC, USART and USB. I don't know how to incorporate them into the APP_Tasks() state machine. For example, the application should monitor the ADC, USART and USB. When there is signal in ADC then it should be serviced. At this point, the USB or USART may be being used or maybe they are not being used. Whatever the state of USB or USART, it should stop the USB and USART and service the ADC. How to incorporate such logic into the state machine? |
|
相关推荐
12个回答
|
|
使用3个独立的状态机,每个ADC,USB和USAT一个。
以上来自于百度翻译 以下为原文 Use 3 separate state machines, one for each ADC, USB and USART. |
|
|
|
当有ADC信号时,如何停止USB、USAT状态机的执行(暂停)?相互创造互动…
以上来自于百度翻译 以下为原文 how do i stop execution(pause) of USB, USART state machines when there is ADC signal? create interaction with each other... |
|
|
|
为什么暂停其他状态机?每个状态机的各个步骤应该足够小,以便不需要中断。这是使用状态机的全部目的。任何需要更快响应的任何东西都应该使用状态机之间的中断。WRT通信,只需使用标志。例如ADC状态机设置的NealADCValueEdiy标志,USAT状态机读取(重新设置)以发送值。
以上来自于百度翻译 以下为原文 Why pause the other state machines? The individual steps of each state machine should be small enough so as not to need interrupting. That is the whole purpose of using state machines. Anything needing much faster response should use interrupts. WRT communication between state machines, just use flags. E.g. ADC state machine sets 'NewADCValueReady' flag, which the USART state machine reads (and re-sets) to inittiate sending the value. |
|
|
|
状态机可以有一个空闲状态,它本身不做任何事情,并等待外部事件或信号量从该状态转换为活动状态。
以上来自于百度翻译 以下为原文 A state machine can have an IDLE state that does nothing in itself and waits for an external event or semaphore to change out of that state to an active state. |
|
|
|
但是,例如,如果USB正在发送音频,并且它的状态机继续运行,而我在ADC中接收到一些东西,USB会继续发送音频吗?我想停止USB发送音频,如果我在ADC中接收到有关编码的东西:我的USB正在发送音频,我在ADC中接收信号,并且它产生中断,NealADCValueEdiy标志设置在这一点上,USB状态机如何读取标志?优选地,在USB扬声器示例FSM中哪个状态可以很好地结合对标志的读取?非常感谢
以上来自于百度翻译 以下为原文 but for example if USB is sending audio, and its state machine keeps on running, while I receive something in ADC, would the USB keep sending audio? I would like to stop USB sending audio, if i receive something in ADC. relating to coding: my u*** is sending audio, i receive signal in ADC and it generates interrupt, NewADCValueReady flag is setup at this point, how does the USB state machine read the flag? preferably in which state in USB speaker example fsm would be good to incorporate the reading of the flag? much thanks |
|
|
|
当有ADC信号时,如何停止USB、USAT状态机的执行(暂停)?你要做的就是所谓的“协作多任务”。你从主循环中依次调用每个状态机函数。每个状态机函数必须做少量的工作和返回,并且永远不要阻塞(例如,永远不要等待标志)。你能做的工作量取决于每个外围设备的服务频率。
以上来自于百度翻译 以下为原文 how do i stop execution(pause) of USB, USART state machines when there is ADC signal? create interaction with each other... You don't. What you are trying to do is called "co-operative multi-tasking". You call each state machine function in turn from your main loop. Each state machine function must do a small amount of work and return and never block (e.g., never sit waiting for a flag). The amount of work you can do depends on how often each peripheral must be serviced. |
|
|
|
当有ADC信号时,如何停止USB、USAT状态机的执行(暂停)?你要做的就是所谓的“协作多任务”。你从主循环中依次调用每个状态机函数。每个状态机函数必须做少量的工作和返回,并且永远不要阻塞(例如,永远不要等待标志)。您可以做的工作量取决于每个外围设备的服务频率。嗯,但是,例如,如果在某个时刻,USB正在传输音频,而我得到ADC信号,则必须停止通过USB的音频传输(要求)。那么,如何做到这一点呢?我假设应用程序有某种方式跳出USB状态机并进入ADC状态机,如何做到这一点?在编码和状态机的点或状态方面,或者创建一个新的状态,专门用于移动/退出状态机
以上来自于百度翻译 以下为原文 how do i stop execution(pause) of USB, USART state machines when there is ADC signal? create interaction with each other... You don't. What you are trying to do is called "co-operative multi-tasking". You call each state machine function in turn from your main loop. Each state machine function must do a small amount of work and return and never block (e.g., never sit waiting for a flag). The amount of work you can do depends on how often each peripheral must be serviced. hmm..., but for example, if at some point, USB is transferring audio, and i get ADC signal, the audio transfer via USB has to be stopped(requirement). so how does one achieve that? i assume the application has somehow to jump out of the USB state machine and enter the ADC state machine, how to do that? in terms of coding and at which point or state of the state machine or create a new state specifically for moving in/out of state machine |
|
|
|
你需要改变你看待这个问题的方式。你有RTOS心态。你需要把它转换成状态机的心态(或者换成RTOS)。有一个调用所有状态机的循环。每个状态机做一小块并退出。例如,USB状态机不将文件全部发送到一个。它执行一些小任务和退出。下一次它被调用,它做另一个小回合。等等,直到完成整个任务。ADC是另一个在USB之间调用的状态机,因此,它们在某种程度上同时执行。如果您希望USB状态机行为响应ADC状态机中发生的某些事情而改变,则只需设置一个标志。然后,确保每次调用“机器机器”时,它检查标志并相应地改变其行为。
以上来自于百度翻译 以下为原文 You need to change the way you look at this. You have RTOS mentality. You need to change it into the state machine mentality (or alternatively you change to RTOS). There's a loop which calls all the state machines. Each state machine does a small piece and quit. For example, USB state machine doesn't send the file all at one. It performs some small task and quits. Next time it is called, it does another small bout. And so on, until the whole assignment is done. ADC is another state machine which gets called in between the USB, so they, sort of, execute at the same time. If you want the USB state machine behaviour to change in response to something which happens in the ADC state machine, you just set a flag. Then you make sure that every time USB state machine gets called, it checks the flag and changes its behaviour accordingly. |
|
|
|
不想与上述评论相矛盾的是FSM。特别是空闲状态和等待状态必须被理解和严格执行!但是如果你跳过没有任何任务的任务,你可以获得巨大的速度增益。在我的情况下,因子20!为此,您需要一个“任务管理器”。一个包含所有必须调用的任务的表。一个简单的解决方案是添加和移除任务,更复杂的是对每个任务都有跳过计数。任务为任务设置跳过计数,然后不再调用跳过计数次数的任务。跳过计数为100到500就足够了,更高的计数只能进行边际改进。如果任务知道必须等待多个字符到达串行或ETE或等待给定的时间,这会产生巨大的差异。但是,管理任务管理器需要额外的编码EF。另外,您可以在以后添加任务(可能是配置相关的),或者完全删除不再需要的任务(例如安装任务)。
以上来自于百度翻译 以下为原文 Not wanting to contradict the above comments re the FSM. Especially the idle state and wait states have to be understood and strictly implemented! But you can get a huge speed gain, if you skip tasks that have nothing to do. In my case factor 20! For that, you need a "task manager". A table that contains all the task that have to be called. A simple solution is to add and remove tasks, a more sophisticated one is to have a skip count for every task. A task sets the skip count for a task and then that task is no longer called for skip count times. Skip counts of 100 to 500 are sufficient, higher counts only make marginal improvements. This makes tremendous difference if a task knows that it has to wait for several chars to arrive over serial or ETH or waiting for a given amount of time. But managing that task manager takes some extra coding effort. Also, you can add tasks (maybe configuration dependent) at a later time, or completely remove tasks that are no longer needed (like a setup task). Nick |
|
|
|
当有ADC信号时,如何停止USB、USAT状态机的执行(暂停)?创建相互作用……可以在应用程序状态机之间创建交互。您可以创建可从所有任务访问的全局数据结构。使用此数据结构在任务之间传递信息。使用访问器/修饰符函数修改数据结构的成员。
以上来自于百度翻译 以下为原文 how do i stop execution(pause) of USB, USART state machines when there is ADC signal? create interaction with each other... It is possible to create interactions between application state machines. You can create a global data structure that is accessible from all tasks. Use this data structure to communicate information between tasks. Use accessor/modifier functions to modify the members of the data structure. |
|
|
|
我能举个例子吗?对不起,我不是那么精通,但我可以为你效劳。
以上来自于百度翻译 以下为原文 can i have example? sorry, i am not that proficient, but example could work for me |
|
|
|
最简单的思想是由Tez——通过全局变量交互的状态机给出的。扩展这一思想是由外围驱动程序使用的回调处理程序,如用来指示音频USB缓冲器已填充并可用于输出到DAC以回放的(参见UBS扬声器实例)。这些回调处理程序例程被注册到每个驱动器(其中每个驱动器是T)。在主轮询循环中询问状态机。驱动程序事件调用回调处理程序,更新这些全局标志。在AppHytasks-()状态机中,关于协调外围设备(USB、ADC、USAT)的动作的原始问题可以使用全局标志、全局缓冲器和来自驱动程序的事件回调来更新这些标志并指示数据可用。在主轮询循环中的任何外围或应用任务例程(参见SysStaskType)占用循环中其他任务例程所需的时间太多。
以上来自于百度翻译 以下为原文 The simplest idea is given by Tez--state machines that interact via global variables. Extending this idea are callback handlers used by the peripheral drivers, like those used to indicate a audio USB buffer has filled and is available to output to the DAC for playback (see the u***_speaker example). These callback handler routines are registered to each driver (where each driver is a tasked state machine in the main polling loop). Driver event call the callback handler routine that updates these global flags. Your original question about coordinating the actions of the peripherals (u***, adc, usart) within an APP_Tasks() state machine could use global flags, global buffers, and event callbacks from the drivers updating these flags and indicating data was available. The trick, as was described, is preventing any of the peripheral or application task routines in the main polling loop (see SYS_Tasks) from taking too much time needed for the other task routines in the loop. There are many examples of this in Harmony. |
|
|
|
只有小组成员才能发言,加入小组>>
5159 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2223 浏览 5 评论
724浏览 1评论
610浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
499浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
623浏览 0评论
522浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-20 11:32 , Processed in 1.549071 second(s), Total 100, Slave 84 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号