/*****************pms150g电笔**********************/
/*****************qq:774145445*********************/
/*****************ID:共同学习stm8******************/
/*****************ide:0.98A4_20230708**************/
/**************************************************/
// pms150g
// ______ ______
// 5v-|1-vdd \_/ gnd-8|-gnd ________
// led_g-|2-pa7 pa0-7|-jiance--|__10M___|----| ________
// led_r-|3-pa6 pa4-6|-bijiao--|__15M___|----|---|__4.7M__|--------220v
// gnd-|4-pa5_____pa3-5|-feng----|__10R___|--------------------------蜂鸣器
#include "extern.h"
void chushihua(); //初始化
led_g bit pa.7;
led_r bit pa.6;
feng bit pa.3;
jiance bit pa.0;
bijiao bit pa.4;
/**************************************************/
void FPPA0 (void)
{
//.ADJUST_IC SYSCLK=IHRC/16 // SYSCLK=1M
//.ADJUST_IC SYSCLK=ILRC;
.ADJUST_IC DISABLE; // No adjust IHRCR, WatchDog Enable
clkmd =0xf4; //系统时钟ilrc
clkmd.4 =0; //关闭ihrc
chushihua();
/**************************************************/
byte a1;
word a2;
led_r =1;
led_r =0;
led_g =1;
led_g =0;
a1 =10;
while(a1--)
{
a2 =200;
while(a2 --)
{
//if(feng ==1){feng =0;} else{feng =1;}
pa ^=1 <<3; //响蜂鸣器
}
feng =0;
a2 =100;
while(a2 --)
{
//if(led_g ==1){led_g =0;} else{led_g =1;}
//pa ^=1 <<7; //闪绿灯
led_g =1;
.delay 30;
led_g =0;
.delay 70;
}
led_g =0;
}
while (1)
{
stopsys; //进入掉电模式
if(jiance ==1)
{
led_r =1;
.delay 500;
led_r =0;
.delay 500;
}
}
}
/**************************************************/
/*
void Interrupt (void)
{
pushaf;
if (Intrq.T16)
{ // T16 Trig
// User can add code
Intrq.T16 = 0;
//...
}
popaf;
}
*/
/**************************************************/
void chushihua() //初始化
{
$ led_g out,low;
$ led_r out,low;
$ feng out,low;
$ jiance in,X_PH, X_PL; //输入,关闭上拉电阻,关闭下拉电阻
$ bijiao in,X_PH, X_PL;
padier =0b1110_1001; //pa4数字停用
}
/**************************************************/
/**************************************************/
/**************************************************/
/**************************************************/
|