有库函数啊,定时中断
不明有庫函數, 是什麼, 我是新手初學的, 請敎一下
去官网下载MsTimer2.h这个的库文件放到ARDUINO的LIBRARY文件夹里。
#include <MsTimer2.h>
void setup()
{
pinMode(13, OUTPUT);
MsTimer2::set(500, flash); // 500ms period
MsTimer2::start();
}
void loop()
{ }
void flash() {
static boolean output = HIGH;
digitalWrite(13, output);
output = !output;
} 哈哈 谢谢 过几天试试 悠然小调 发表于 2012-3-9 20:35 static/image/common/back.gif
有库函数啊,定时中断
#include
请问这个库在哪里啊? Ryanli 发表于 2013-1-11 15:34 static/image/common/back.gif
请问这个库在哪里啊?
http://playground.arduino.cc/Main/MsTimer2 悠然小调 发表于 2013-1-15 17:49 static/image/common/back.gif
http://playground.arduino.cc/Main/MsTimer2
谢啦,哈哈。 悠然小调 发表于 2012-4-9 16:40 static/image/common/back.gif
去官网下载MsTimer2.h这个的库文件放到ARDUINO的LIBRARY文件夹里。
#include
那个中断和串口还是iic通信有冲突啊,不知道是哪个。反正肯定有冲突,一用就死啊 可以的,下面代码每125us(8KHz)产生一次中断,修改OCR1A 的值可以更改中断频率,
f = 16MHz / (2*(OCR1A + 1));const byte LED = 13;
ISR(TIMER1_COMPA_vect)
{
static boolean state = false;
state = !state;// toggle
digitalWrite (LED, state ? HIGH : LOW);
}
void setup() {
pinMode (LED, OUTPUT);
// set up Timer 1
TCCR1A = 0; // normal operation
TCCR1B = _BV(WGM12) | _BV(CS10); // CTC, no pre-scaling
OCR1A =999; // compare A register value (1000 * clock speed)
TIMSK1 = _BV (OCIE1A); // interrupt on Compare A Match
}// end of setup
void loop() { }This toggles pin D13 faster than you can see (once every 62.5 μS). (It turns on every second toggle, that is every 125 μS, giving a frequency of 1/0.000125 = 8 KHz)
更多interrupt参考:http://www.gammon.com.au/forum/?id=11488 那计数器呢?怎么搞?有什么好的资料啊? 因该是可以用的,sei函数,但是里面的参数看不懂啊,也没有说明 悠然小调 发表于 2012-3-9 20:35 static/image/common/back.gif
有库函数啊,定时中断
#include
这个你会用吗? 终于找到解决方法了,待验证…… iron 发表于 2012-3-6 23:33
Arduino硬件难道没有时钟中断?
硬件当然有 但要操作寄存器
页:
1
[2]