home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1996 September
/
PCWK996.iso
/
demo
/
wgelectr
/
emul51
/
examples
/
adv_tra.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-22
|
1KB
|
62 lines
#pragma code symbols debug objectextend
/****************************************************************
* This code has been written by Nohau Corporation for use *
* with the tutorial for the 'ADVANCED TRACE' board. *
* (c) 1991 by Nohau Corporation *
****************************************************************/
#include <reg51.h>
#include <absacc.h>
#include <intrins.h>
union {
unsigned char c[4];
unsigned long i;
} time = { 0,0,0,0 };
char reload = 0;
void extint0() interrupt 0
{
INT0 = 1; /* clear int. req. pin */
TL0 = reload+1;
TH0 = reload;
TR0 = 1; /* restart timer0 */
}
void timer0() interrupt 1
{
TR0 = 0; /* stop timer0 */
INT0 = 0; /* clear pin to create high level int. */
time.c[0]++; /* increment on timer overflow */
if(time.c[0] == 0xff)
time.c[1]++;
}
void initialize()
{
TCON = 0x00; /* clear control reg. = stop timers */
TMOD = 0x01; /* Timer0 = 16bit timer */
IP = 0x01; /* External int. 0 high level interrupt */
TL0 = reload+1; /* PreLoad timer0 with 0001h */
TH0 = reload;
INT0 = 1; /* assure ext. int. disabled */
IE = 0x83; /* Enable interrupts T0, EX0 */
}
void main()
{
unsigned int delay = 65000;
unsigned int start;
initialize(); /* setup SFR's for test program */
TR0 = 1; /* let timer go */
while(1){
for(start = 0; start < delay ; start++)
time.i++;
}
}