intex1.c
来自「startup code has configured Timer0」· C语言 代码 · 共 38 行
C
38 行
// 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 + =
减小字号Ctrl + -
显示快捷键?