完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include'Filter.h'
#define样本3 #include&lt; math.h&gt; #include&lt; stdlib.h&gt; extern unsigned long int data; long int Result_Previous,Average ,; unsigned char Stable; void FIR_Filter(unsigned long int Clean) { static unsigned char Index = 0; // static bit_16 Index1 = 4000; static unsigned long int ADC_Mean [Samples]; unsigned long int绝对; unsigned char Count; // Average = Clean&gt;&gt; 5; 清洁&gt;&gt; = 5; ADC_Mean [Index] =干净; 平均值= 0; { 为(计数= 0;计数N样本;计数++) { 平均+ = ADC_Mean [COUNT]; } 平均/ =样本; } if(Index&gt; =(Samples-1)) 索引= 0; 其他 指数++; Absolute = abs(Average - Result_Previous); if(绝对&lt; 5) { Average = Result_Previous +((Average - Result_Previous)&gt;&gt; 2); } 如果(绝对&LT; 3) 稳定++; 其他 稳定= 0; Result_Previous =平均值; // return(平均值); data = Average; 这是我在中断函数中的代码..我认为这个语句的问题在变量中没有工作在中断函数'Average + = ADC_Mean [Count];' 怎么能在那个变量中添加? 帮帮我...谢谢.. 以上来自于谷歌翻译 以下为原文 #include 'Filter.h' #define Samples 3 #include #include long int Result_Previous,Average,; unsigned char Stable;void FIR_Filter(unsigned long int Clean) { static unsigned char Index=0; // static bit_16 Index1=4000; static unsigned long int ADC_Mean[Samples]; unsigned long int Absolute; unsigned char Count; // Average = Clean>>5; Clean >>= 5; ADC_Mean[Index] = Clean; Average = 0; { for(Count=0;Count Average+=ADC_Mean[Count]; } Average /= Samples; } if(Index >= (Samples-1)) Index=0; else Index++; Absolute = abs(Average - Result_Previous); if(Absolute <5) { Average = Result_Previous +((Average - Result_Previous)>>2); } if(Absolute<3) Stable++; else Stable=0; Result_Previous = Average; // return (Average); data = Average; }this is my code in interrupt function.. i think problem with this statement addition in variable not working in interrupt function ' Average+=ADC_Mean[Count];' how can addition in that variable?? Help me for this.. Thank you.. |
|
相关推荐
5个回答
|
|
不清楚。中断例程应尽可能短=尽可能少的计算。
什么是触发中断的信号?哪个频率? 尝试在中断中执行最小值,将结果传递到专用的全局寄存器中并设置RAM标志(以防止将来的中断损坏数据)。主循环将等待标志,获取数据,除数并清除标志。 以上来自于谷歌翻译 以下为原文 Unclear. Interrupt routine should be as short as possible = as little computation as possible. What is the signal triggering the interrupt? Which frequency? Try to do the minimum in the interrupt, pass the result in a dedicated global register and set a RAM flag (to prevent future interrupts to corrupt the data). The main loop will wait for the flag, grab the data, divide, and clear the flag. |
|
|
|
如果要在中断处理程序中修改全局变量,并且想要在外部访问它们,则需要将它们声明为“volatile”。
以上来自于谷歌翻译 以下为原文 If you're modifying global variables inside an interrupt handler, and you want to access them outside, you need to declare them as 'volatile'. |
|
|
|
信号触发是下降沿,频率为2MHz。
以上来自于谷歌翻译 以下为原文 Signal triggering is a falling edge and frequency is 2MHz. |
|
|
|
|
|
|
|
你好,
在询问时,在中断函数名之前添加@svlreg。 更详细的说,你在中断(使用long和/或float)下进行复杂的计算,所以你需要添加@svlreg关键字以保存用于此计算的内部寄存器,从而确保它们不是损坏(这会在执行后期造成各种麻烦,调试很困难且耗时)。 问候, 卢卡 以上来自于谷歌翻译 以下为原文 Hello, add the @svlreg before the interrupt function name as you are asked. More in detail, you are doing complex calculations under interrupt (using long and/or floats), so you need to add the @svlreg keyword in order to save the internal registers that are used for this calculation and thus make sure that they are not corrupted (that would cause all kind of trouble later in the execution and is difficult and time-consuming to debug). Regards, Luca |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2634 浏览 1 评论
3208 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1783 浏览 1 评论
3609 浏览 6 评论
5987 浏览 21 评论
939浏览 4评论
1315浏览 4评论
在Linux上安装Atollic TRUEStudio的步骤有哪些呢?
582浏览 3评论
使用DMA激活某些外设会以导致外设无法工作的方式生成代码是怎么回事
1302浏览 3评论
1358浏览 3评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 15:44 , Processed in 1.104564 second(s), Total 54, Slave 47 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号