Youngar
游客
游客
阅读:2057回复:3

About Timer0 ISR

楼主#
更多 发布于:2001-07-23 14:19
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 */
  {
  }
}
nigx
驱动巨牛
驱动巨牛
  • 注册日期2001-04-29
  • 最后登录2018-06-02
  • 粉丝0
  • 关注0
  • 积分14166分
  • 威望71910点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2001-07-23 21:51
该程序是用C51语言编程的。
A处表明 中断执行程序响应是 中断1 的中断服务程序。
B处是让单片机处于等待状态(如果等待外界的中断信号)


关于利用单片机的本身的机制实现中断计数问题可以翻阅单片机书

基本上才有这方面的代码。
jeosph
驱动中牛
驱动中牛
  • 注册日期2001-04-19
  • 最后登录2006-08-08
  • 粉丝0
  • 关注0
  • 积分96分
  • 威望11点
  • 贡献值0点
  • 好评度9点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2001-07-31 11:11
while(1){};<=>
loop:jmp loop
//

br $
    
Youngar
游客
游客
地板#
发布于:2001-07-31 17:45
非常感谢Nigx & Jeosph!
游客

返回顶部