#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=0;
unsigned char flage=1;
void main(void)
{
CPUCS|=0x01; //00-12M
//- - PORTCSTB CLKSPD1 CLKSPD0 CLKINV CLKOE 8051RES
Time0();
Interrupt_Time0_On;
OEA=0x0C;
IOAL(2);
while(1)
{
if(flage)
IOAH(2);
else
IOAL(2);
}
}
void ISR_TINER0(void) interrupt TMR0_VECT using 0
{
number++;
TCON|=0X20;
Time_load();
if(number>=20)
{
number=0;
flage=!flage;
}
}
//==================================================
#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)/255;
TL0=(65536-50000)%255;
}
extern void Time0()
{
TMOD=0X01;
Time_load();
//7:0 GATE C/T M1 M0 GATE C/T M1 M0
TCON|=0X10;
//7:0 TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
T0M=0;
//When TOM=0,Timer 0 uses CLK24/12,When TOM=1,Timer 0 usesCLK24/4
}
#endif
//=============================================
這段斷碼怎么實現不了1s led閃爍呢? |