📄 intex1.c
字号:
// Program 1 from the Using Interrupts example.
// Assumes the startup code has configured Timer0
// for a 25mSec interrupt.
// Ron Kreymborg
#include <avrstdio.h>
void main(void);
void CheckInt(void);
extern char I_Time;
main(void) {
int n;
outp(DDRB,0xff); // all are outputs
outp(PORTB, 0xff); // and all are high
n = 0; // zero counter
while (1) { // do forever
CheckInt(); // wait for interrupt
if (++n == 40) { // if 40 have occured
outp(PORTB, 0x7f); // bit 7 of PORTB low
CheckInt(); // keep low for 25mSec
outp(PORTB, 0xff); // bit 7 high again
n = 0; // ready for next cycle
}
}
}
void CheckInt() {
while (I_Time == 0) // wait
;
I_Time = 0; // must reset flag
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -