/****************WS2812B流水灯*********************/
#include "extern.h"
bit led : pa.0;
byte a1; //显示用
byte xian; //显示标志位
word a2; //t16初值
/**************************************************/
void xianshi(); //显示
/**************************************************/
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
/**************************************************/
/**************************************************/ //中断T16配置
$ inten t16;
intrq =0;
engint //启用全局中断
//disgint //停用全局中断
//$ t16m sysclk,/64,bit15; //timer16启用
$ t16m ilrc,/16,bit11; //timer16启用//1秒中断
//$ t16m stop; //timer16停用
/**************************************************/
$ led out,low;
while (1)
{
if(xian==1)
{
xian =0;
xianshi();
}
.delay 500000;
}
/**************************************************/
}
/**************************************************/
void Interrupt (void)
{
pushaf;
if (Intrq.T16)
{
Intrq.T16 = 0;
a1 ^=1; //异或取反
xian =1; //显示标志位
a2 =0;
stt16 a2; //t16初值
}
popaf;
}
/**************************************************/
void xianshi() //显示
{
if(a1.0){led=1;}
else{led=0;}
}
/**************************************************/
/**************************************************/
/**************************************************/