只是让灯一闪一闪而已。。。
#include<sh79f166a.h>
void init_2(void);
void main()
{
P0SS = 0x00; //IO的初始化
P0CR = 0xff;
P0PCR = 0xff;
P0 = 0xff;
CLKCON = 0x60; // 1Mhz,12分频
init_2(); //定时器2设置
while(1);
}
void time2_(void) interrupt 8 //延时,P0取反
{
static char i,k;
i++;
if(i == 100)
{
k++;
i = 0;
if(k == 100)
{
k = 0;
P0 = ~P0;
}
}
}
void init_2(void)
{
T2CON = 0x00;
TL2 = 0x29;
TH2 = 0xff;
IEN0 |= 0xa0;
TR2 = 1;
} |