阅读:2087回复:3
About Timer0 ISR
Hi,All;
(1)A处怎么多了"interrupt 1"? (2)B处While的用法?空语句?请详细讲解? (3)实在搞不清楚如何实现每65536个时钟就中断一次,还请您详细讲解. Thanks in advance. ***Source Code*** #include <reg52.h> #include <stdio.h> /*------------------------------------------------ Timer 0 Interrupt Service Routine. ------------------------------------------------*/ static unsigned long overflow_count = 0; void timer0_ISR (void) interrupt 1 /* A */ { overflow_count++; /* Increment the overflow count */ } /*------------------------------------------------ MAIN C function ------------------------------------------------*/ void main (void) { /*-------------------------------------- Set Timer0 for 16-bit timer mode. The timer counts to 65535, overflows, and generates an interrupt. Set the Timer0 Run control bit. --------------------------------------*/ TMOD = (TMOD & 0xF0) | 0x01; /* Set T/C0 Mode */ ET0 = 1; /* Enable Timer 0 Interrupts */ TR0 = 1; /* Start Timer 0 Running */ EA = 1; /* Global Interrupt Enable */ /*-------------------------------------- Do Nothing. Actually, the timer 0 interrupt will occur every 65536 clocks. --------------------------------------*/ while (1) /* B */ { } } |
|
沙发#
发布于:2001-07-23 21:51
该程序是用C51语言编程的。
A处表明 中断执行程序响应是 中断1 的中断服务程序。 B处是让单片机处于等待状态(如果等待外界的中断信号) 关于利用单片机的本身的机制实现中断计数问题可以翻阅单片机书 基本上才有这方面的代码。 |
|
板凳#
发布于:2001-07-31 11:11
while(1){};<=>
loop:jmp loop // br $ |
|