/*******************五线数码管*********************/
/********************PMS150G***********************/
/****************QQ774145445***********************/
/****************快手:共同学习STM8*****************/
/****************20200926**************************/
/**************************************************/
//__________________________________________
//| __2a__ __3a__ 4a 4b |
//| 1a| | | | | IN OUT |
//| | 2f| 2b| 3f| 3b| 4c 4d |
//| __2g__ __3g__ 5V 2.1A |
//| 1b| | | | | |
//| | | | 3e| 3c| 4e 4f 4g |
//| __2d__ __3d__ % 5V 1.0A |
//| @1 @2 @3 @4 @5 |
//|_________________________________________|
/**************************************************/
//__________________________________________
//| | 1- | 2- | 3- | 4- | 5- |
//| 1+ | ** | 2f | 2b | 2d | 2g |
//| 2+ | 1a1b | ** | 3a | 3c | 3f |
//| 3+ | 2a | 3g | ** | 4e | 4b |
//| 4+ | 2c | 3b | 3d | ** | 4f4g |
//| 5+ | 2e | 3e | 4a | 4c4d | ** |
//|_________________________________________|
/**************************************************/
// ------@------
// --|VDD GND|--
// @4--|PA7 PA0|--@1
// @5--|PA6 PA4|--@2
// --|PA5 PA3|--@3
// -------------
/**************************************************/
/**************************************************/
led_1 bit pa.0; //@1
led_2 bit pa.4; //@2
led_3 bit pa.3; //@3
led_4 bit pa.7; //@4
led_5 bit pa.6; //@5
/**************************************************/
void xianshi_fenjie(); //显示分解
void xianshi(); //显示
void yanshi(); //延时
byte xianshi_a1; //要显示的数字0-199
byte xianshi_c1; //百位字模
byte xianshi_c2; //十位字模
byte xianshi_c3; //个位字模
#include "extern.h"
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
byte a1=0;
$ led_1 out;
$ led_2 out;
$ led_3 out;
$ led_4 out;
$ led_5 out;
xianshi_a1=0;
xianshi_fenjie();
while(1)
{
a1++;
if(a1>60)
{
a1=0;
xianshi_fenjie();
xianshi_a1++;
if(xianshi_a1>199){xianshi_a1=0;}
}
xianshi();
}
}
/**************************************************/
void xianshi_fenjie() //显示分解
{
byte xianshi_b1; //百位
byte xianshi_b2; //十位
byte xianshi_b3; //个位
byte xianshi_b4;
xianshi_b1 =0;
xianshi_b2 =0;
xianshi_b3 =0;
xianshi_b4 =xianshi_a1;
while(xianshi_b4>99) //代替除法计算出百位
{
xianshi_b4 -=100;
xianshi_b1 ++;
}
while(xianshi_b4>9) //代替除法计算出十位
{
xianshi_b4 -=10;
xianshi_b2 ++;
}
xianshi_b3 =xianshi_b4; //个位
/**************************************************/ //查表
//共阳0-9//0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90
xianshi_c1 =xianshi_b1; //百位
if (xianshi_b2 ==0){xianshi_c2 =0xc0;} //0十位字模
if (xianshi_b2 ==1){xianshi_c2 =0xf9;} //1
if (xianshi_b2 ==2){xianshi_c2 =0xa4;} //2
if (xianshi_b2 ==3){xianshi_c2 =0xb0;} //3
if (xianshi_b2 ==4){xianshi_c2 =0x99;} //4
if (xianshi_b2 ==5){xianshi_c2 =0x92;} //5
if (xianshi_b2 ==6){xianshi_c2 =0x82;} //6
if (xianshi_b2 ==7){xianshi_c2 =0xf8;} //7
if (xianshi_b2 ==8){xianshi_c2 =0x80;} //8
if (xianshi_b2 ==9){xianshi_c2 =0x90;} //9
if (xianshi_b3 ==0){xianshi_c3 =0xc0;} //0个位字模
if (xianshi_b3 ==1){xianshi_c3 =0xf9;} //1
if (xianshi_b3 ==2){xianshi_c3 =0xa4;} //2
if (xianshi_b3 ==3){xianshi_c3 =0xb0;} //3
if (xianshi_b3 ==4){xianshi_c3 =0x99;} //4
if (xianshi_b3 ==5){xianshi_c3 =0x92;} //5
if (xianshi_b3 ==6){xianshi_c3 =0x82;} //6
if (xianshi_b3 ==7){xianshi_c3 =0xf8;} //7
if (xianshi_b3 ==8){xianshi_c3 =0x80;} //8
if (xianshi_b3 ==9){xianshi_c3 =0x90;} //9
}
/**************************************************/
void xianshi() //显示
{
$ led_1 out,high; //第一种状态
$ led_2 in;
$ led_3 in;
$ led_4 in;
$ led_5 in; //消隐
if(!xianshi_c2.5) {$ led_2 out,low;} //2f
if(!xianshi_c2.1) {$ led_3 out,low;} //2b
if(!xianshi_c2.3) {$ led_4 out,low;} //2d
if(!xianshi_c2.6) {$ led_5 out,low;} //2g
yanshi();
$ led_1 in; //第二种状态
$ led_2 out,high;
$ led_3 in;
$ led_4 in;
$ led_5 in; //消隐
if(xianshi_c1) {$ led_1 out,low;} //%1a1b
if(!xianshi_c3.0) {$ led_3 out,low;} //3a
if(!xianshi_c3.2) {$ led_4 out,low;} //3c
if(!xianshi_c3.5) {$ led_5 out,low;} //3f
yanshi();
$ led_1 in; //第三种状态
$ led_2 in;
$ led_3 out,high;
$ led_4 in;
$ led_5 in; //消隐
if(!xianshi_c2.0) {$ led_1 out,low;} //2a
if(!xianshi_c3.6) {$ led_2 out,low;} //3g
//if(xianshi_c2.3){led_4 =0;} //4e
$ led_4 out,low; //百分号
//if(xianshi_c2.6){led_5 =0;} //4b
yanshi();
$ led_1 in; //第四种状态
$ led_2 in;
$ led_3 in;
$ led_4 out,high;
$ led_5 in; //消隐
if(!xianshi_c2.2) {$ led_1 out,low;} //2c
if(!xianshi_c3.1) {$ led_2 out,low;} //3b
if(!xianshi_c3.3) {$ led_3 out,low;} //3d
//if(xianshi_c2.6){led_5 =0;} //4f4g
yanshi();
$ led_1 in; //第五种状态
$ led_2 in;
$ led_3 in;
$ led_4 in;
$ led_5 out,high ;//消隐
if(!xianshi_c2.4) {$ led_1 out,low;} //2e
if(!xianshi_c3.4) {$ led_2 out,low;} //3e
//if(xianshi_c2.3){led_3 =0;} //4a
//if(xianshi_c2.6){led_4 =0;} //4c4d
yanshi();
/*
if(xianshi_c2.4){$ led_1 in;} else{$ led_1 out,low;} //2e
if(xianshi_c3.4){$ led_2 in;} else{$ led_2 out,low;} //3e
//if(xianshi_c2.3){led_3 =0;} //4a
//if(xianshi_c2.6){led_4 =0;} //4c4d
yanshi();
*/
}
/**************************************************/
void yanshi() //延时
{
.delay 7000;
}
/**************************************************/
/**************************************************/
/**************************************************/
/**************************************************/ |