Professional Documents
Culture Documents
Bbs Viewthread - PHP Tid 16673
Bbs Viewthread - PHP Tid 16673
Page 1 of 3
สมัครสมาชิก เขาระบบ
Electoday.com » AVR » Timer Interrupt เรื่อง period เพี้ยน ชวยหนอยครับ Arduino 328 ETT
มาใหม
คือ ผมใช Timer Interrupt แลวใหผลไมตรงกับคา period ที่ set เอาไวครับ
UID 8482 คา Period เปน 1000000 us หรือ 1 sec ทดลองบน Proteus ใหผลถูกตอง
กระทู 42 แตพอเอามาลงบอรดจริง ๆ period มันเพี้ยนไปเลย แบบ เร็วมาก ๆ ดูไมทันครับ
เครดิต 42 ผมใชบอรด ETT 328 นะครับ ใครรูวิธีแกรบกวนหนอยนะครับ
ผลงาน 42
Money 0
1. #include "TimerOne.h"
เพศ ชาย
2. void setup()
ออนไลน 24 ชั่วโมง
3. {
เขามาลา 2012-3-24
4. Timer1.initialize(1000000);
5. Timer1.attachInterrupt(callback);
6. Serial.begin(9600);
7. }
8.
9. void callback()
10. {
11. Serial.println("Serial Test");
12. }
13.
14. void loop()
15. {
16.
17. }
คัดลอกไปที่คลิปบอรด
บรรณาธิการบริหาร
1. #include <TimerOne.h>
2.
UID 25
3. void setup()
กระทู 1858
4. {
เครดิต 1208
ผลงาน 1208 5. Timer1.initialize(1000000);
Money 0 6. Timer1.attachInterrupt(callback);
เพศ ชาย 7. Serial.begin(9600);
จาก 38.64°N 8. }
ออนไลน 1648 ชั่วโมง 9.
เขามาลา 2012-4-20
10. void callback()
http://www.electoday.com/bbs/viewthread.php?tid=16673 20/4/55
Timer Interrupt เรื่อง period เพี้ยน ชวยหนอยครับ Arduino 328 ETT - AVR - Electoday.... Page 2 of 3
11. {
12. Serial.println("Serial Test");
13. }
14.
15. void loop()
16. {
17. int count = 0;
18. while ( 1 ) {
19. Serial.println( "in loop");
20. delay( 500);
21. if ( count == 10) {
22. Timer1.stop();
23. while( 1) ;
24. }
25. else count++;
26. }
27. }
คัดลอกไปที่คลิปบอรด
ผลคือ
in loop
in loop
Serial Test
in loop
in loop
Serial Test
in loop
in loop
Serial Test
in loop
in loop
Serial Test
in loop
in loop
Serial Test
in loop
กองบรรณาธิการ
UID 1461
กระทู 1384
เครดิต 1288
ผลงาน 1288
Money 0
เพศ ชาย
ออนไลน 781 ชั่วโมง
เขามาลา 2012-4-20
เลนดวย
http://www.electoday.com/bbs/viewthread.php?tid=16673 20/4/55
Timer Interrupt เรื่อง period เพี้ยน ชวยหนอยครับ Arduino 328 ETT - AVR - Electoday.... Page 3 of 3
I love arduino
ตอบกลับ อางอิง TOP
ขอบคุณครับ แกไดแลวครับ ผมลง IDE และ Library ใหมหมดเลย จาก ETT ผลการทดลองออกมาถูก
ตองครับ
แตก็ยังไมรูอยูดีวามันไปผิดพลาดอะไร
มาใหม
UID 8482
กระทู 42
เครดิต 42
ผลงาน 42
Money 0
เพศ ชาย
ออนไลน 24 ชั่วโมง
เขามาลา 2012-3-24
กลับไปหนารายชื่อกระทู
Powered by Discuz! 7.0.0 Electoday Forum Provide by Micro4you.com | ติดตอเรา | สถิติบอรด | Archiver | WAP
© 2001-2009 Comsenz Inc. GMT+7, 2012-4-20 23:40, Processed in 0.055621 second(s), 7 queries, Gzip enabled.
http://www.electoday.com/bbs/viewthread.php?tid=16673 20/4/55