34af9uc的个人空间 https://bbs.21ic.com/?818997 [收藏] [复制] [RSS]

日志

应广单片机 T16的设计

已有 171 次阅读2020-9-5 18:42 |系统分类:兴趣爱好

/****************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;}
}
/**************************************************/
/**************************************************/
/**************************************************/


路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)