/********************QQ774145445*******************/
/*****************快手:共同学习STM8****************/
/****************108khz微孔雾化片******************/
/********************20201030*********************/
#include "extern.h"
anjian bit pa.4;
led bit pa.6;
wuhuapian bit pa.3;
void yanshi(); //延时
void huxideng(); //呼吸灯
byte yanshi_a1; //延时用
byte huxi_a1,huxi_a2;
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/2, IHRC=15MHz, VDD=5V;
/**************************************************/
$ wuhuapian in,low;//High / Low置低
$ tm2c ihrc,pa3,pwm;
//tm2ct //tim2计数寄存器
//tm2b //上限寄存器
$ tm2s 6bit,/1,/2; //117.64khz
tm2b =31;//127;
/**************************************************/
$ led out,low; //high
/**************************************************/
yanshi_a1 =100; //最大130最小10
while (1)
{
huxideng();
}
}
/**************************************************/
void huxideng() //呼吸灯
{
//yanshi_a1 =100; //最大130最小10
/**************************************************/ //渐亮
huxi_a1 =19;
huxi_a2 =20; //10
while(!(huxi_a2==85))
{
huxi_a1 ++;
if(huxi_a1==huxi_a2)
{
led =0;
}
if(huxi_a1==100)
{
led =1;
huxi_a1 =0;
huxi_a2 ++;
}
yanshi();
}
/**************************************************/ //渐暗
huxi_a1 =19;
huxi_a2 =20; //10
while(!(huxi_a2==85))//100-10//100
{
huxi_a1 ++;
if(huxi_a1==huxi_a2) //比较打开
{
led =1;
}
if(huxi_a1==100) //关闭
{
led =0;
huxi_a1 =0;
huxi_a2 ++;
}
yanshi();
}
led=1;
//yanshi_a1 -=1;
/**************************************************/
}
/**************************************************/
void yanshi() //延时
{
byte yanshi_a2;
yanshi_a2 =yanshi_a1;
while(yanshi_a2)
{
yanshi_a2 -=1;
nop;
nop;
nop;
nop;
nop;
nop;
}
}
/**************************************************/
/*
void Interrupt (void)
{
pushaf;
if (Intrq.T16)
{ // T16 Trig
// User can add code
Intrq.T16 = 0;
//...
}
popaf;
}
*/
|