#include "HT48C06.h"
#pragma vector isr_Timer @ 0x08 //Timer
unsigned int
Occupy_led;
maikuan;
light;
m;
void System_Initial()
{
_intc=0;
Timer0_Init:
_tmr = 256-125;
_tmrc = 0b10010010; // Timer Mode / Open Timer / UpData add cup4M/4 1us
_eti = 1; //On Timer Interrupt //tf //_t0e
All_Interrupt:
_emi = 1; //On All Interrupt
}
void main()
{
Occupy_led=0;
maikuan=0;
light=1;
_pac=0;
_pa0=_pa1=_pa2=_pa3=_pa4=_pa5=_pa6=_pa7=0;
System_Initial();
while(1)
{
_clrwdt();
while(maikuan!=Occupy_led)
{
_pa5=_pa6=_pa7=0;
}
while(maikuan!=255)
{
_pa5=_pa6=_pa7=1;
}
maikuan=0;
if(light)
{
Occupy_led++;
}
else
{
Occupy_led--;
}
if(Occupy_led==255 || Occupy_led==0)
light=!light;
}
}
void isr_Timer()
{
maikuan++;
//-------------------T0 Timer Interrupt Exit
// _tf=0;
}
调试很久了,在仿真器上可以实现没有问题,但是下到单片机上就不正常了,不知道怎么回事,麻烦大家帮我看看 |