#include "herder\fx2.h"
#include "herder\fx2regs.h"
#define ioah(x) ioa|=(1<<x)
#define ioal(x) ioa&=(~(1<<x))
#include "herder\time.h"
unsigned int number=02
unsigned char flage=12
void main(void)
{
cpucs|=0x012 //00-12m
//- - portcstb clkspd1 clkspd0 clkinv clkoe 8051res
time0()2
interrupt_time0_on2
oea=0x0c2
ioal(2)2
while(1)
{
if(flage)
ioah(2)2
else
ioal(2)2
}
}
void isr_tiner0(void) interrupt tmr0_vect using 0
{
number++2
tcon|=0x202
time_load()2
if(number>=20)
{
number=02
flage=!flage2
}
}
//==================================================
#ifndef _time_h_
#define _time_h_
#define interrupt_time0_on ie|=0x82
//ie ea es1 et2 es0 et1 ex1 et0 ex0
//ckcon - - t2m t1m t0m md2 md1 md0
extern void time_load()
{
th0=(65536-50000)/2552
tl0=(65536-50000)%2552
}
extern void time0()
{
tmod=0x012
time_load()2
//7:0 gate c/t m1 m0 gate c/t m1 m0
tcon|=0x102
//7:0 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0
t0m=02
//when tom=0,timer 0 uses clk24/12,when tom=1,timer 0 usesclk24/4
}
#endif
//=============================================
|