gpt4 book ai didi

c - 在c中用覆盆子采样

转载 作者:行者123 更新时间:2023-11-30 16:43:05 25 4
gpt4 key购买 nike

我需要每 4 毫秒模拟读取一次,但我测试了我的代码读取执行时间并打印了以下内容:

enter image description here

这不是4ms,我的代码:

#include <time.h>

clock_t start,end;
double tempo;

for(i=1; i <= 20; i++) {
start=clock();
x = analogRead (BASE + chan);
printf("%d\n", x);
delay(4);
end=clock();
tempo=((double)(end-start))/CLOCKS_PER_SEC;
printf("%f \n", tempo);
}

最佳答案

您使用什么功能并不重要,因为 Linux 不是 RTOS,因此您实际上可以忘记实时功能,除非您使用 PREEMPT_RT 修补内核。网上有很多关于这个主题的信息。

对于一个如此答案来说,这是一个复杂的主题,但我希望我能为您指出正确的方向。

关于c - 在c中用覆盆子采样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45523607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com