打印

PFC460TSSOP28@6p数码管

[复制链接]
449|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
34af9uc|  楼主 | 2022-1-16 14:55 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
/*******************************************PFC460TSSOP28********************************************/
/*****************************************应广单片机编程第十季***************************************/
/*****************************************QQ:774145445***********************************************/
/*****************************************快手:共同学习stm8******************************************/
/*****************************************IDE:PADAUK_0.92B2******************************************/
#include        "extern.h"
/****************************************************************************************************/
//                                             pfc460/tssop28
//                                         __________   __________
//                                       -|1--pc2    \_/    pc1-28|-
//                                       -|2--vdd           gnd-27|-
//                                       -|3--pc3           pc0-26|-
//                                       -|4--pc4           pc5-25|-
//                                       -|5--pa7           pa0-24|-
//                           cs0(33nx7r) -|6--pa6           pa4-23|-
//                                       -|7--pa2           pa1-22|-
//                                       -|8--pa5           pa3-21|-
//                                       -|9--pa7           pb3-20|-
//                                       -|10-pb4           pb1-19|-@4
//                                       -|11-pc6           pc7-18|-@5
//                                       -|12-pb5           pb0-17|-@3
//                                       -|13-pd0           pd1-16|-@2
//                                       -|14-pb6___________pb2-15|-@1
/****************************************************************************************************/
//                                       led8.8.8./cs3631aw-4-d
//                 _______________________________________________________________________
//                |         @1        @2        @3        @4        @5        @6          |
//                |          ___1a____            ____.0___            _________          |
//                |         |         |          |         |          |         |         |
//                |        1f        1b         .5        .1          |         |         |
//                |         |         |          |         |          |         |         |
//                |          ---1g----            ---.6----            ---------          |
//                |         |         |          |         |          |         |         |
//                |        1e        1c 1h      .4        .2 .7       |         |         |
//                |         |___1d____| o        |___.3____| o        |_________| o       |
//                |_______________________________________________________________________|

//                               ___________________________________
//                              |_1高_|__1f_|__1g_|__1c_|__1d_|__3d_|
//                              |__1a_|_2高_|__2f_|__2g_|__2c_|_____|
//                              |__1b_|__2a_|_3高_|__3f_|__3g_|__3e_|
//                              |__1e_|__2b_|_____|_4高_|__3a_|_____|
//                              |_____|__2e_|__3b_|__3c_|_5高_|_____|
//                              |__1h_|__2d_|__2h_|__3h_|_____|_6高_|
//                    @1--pb2    @2--pd1    @3--pb0    @4--pb1    @5--pc7    @6--pb3

//共阳:0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90//0x88,0x83,0xc6,0xa1,0x86,0x8e
//共阴:0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f//0x77,0x7c,0x39,0x5e,0x79,0x71
/****************************************************************************************************/               
void        FPPA0 (void)
{
        .ADJUST_IC        SYSCLK=IHRC/4                //        SYSCLK=IHRC/4

        //        Insert Initial Code
//        pmode        Program_Mode;                        //        if has more FPPAs than 2
        pmode                6;
        fppen        =        0xFF;




        while (1)
        {

        }
}
/****************************************************************************************************/
word                xianshi_a1;                                                                //显示总数据
byte                xianshi_b1,xianshi_b2,xianshi_b3;                //百位,十位,个位
byte                xianshi_qumo_a1;                                                //取模用
byte                xianshi_c1,xianshi_c2,xianshi_c3;                //百位字模,十位字模,个位字模

led_1                bit                pb.2;
led_2                bit                pd.1;
led_3                bit                pb.0;
led_4                bit                pb.1;
led_5                bit                pc.7;
led_6                bit                pb.3;
void                xianshi();                                //显示
void                xianshi_jisuan();                //显示计算
void                xianshi_qumo();                        //显示取模
void                xianshi_yanshi();                //显示延时
void        FPPA1 (void)
{
byte                a1;
xianshi_a1                =0;


while(1)
{
xianshi_a1++;
if(xianshi_a1>999){xianshi_a1        =0;}
xianshi_jisuan();
a1=75;                //75hz
while(a1--)
{
xianshi();
}

}
}
/****************************************************************************************************/
void        FPPA2 (void)
{
        goto        $;
}
/****************************************************************************************************/
void        FPPA3 (void)
{
        goto        $;
}
/****************************************************************************************************

void        Interrupt (void)
{
        pushaf;

        if (Intrq.T16)
        {        //        T16 Trig
                //        User can add code
                Intrq.T16        =        0;
                //...
        }

        popaf;
}

/****************************************************************************************************/
void        xianshi()                //显示
{
/**************************************************/                //第一种
$                led_1                out,high;
$                led_2                in;
$                led_3                in;
$                led_4                in;
$                led_5                in;
$                led_6                in;
//if(){$        led_1        out,low;}
if(xianshi_c1.5){$        led_2        out,low;}                //1f
if(xianshi_c1.6){$        led_3        out,low;}                //1g
if(xianshi_c1.2){$        led_4        out,low;}                //1c
if(xianshi_c1.3){$        led_5        out,low;}                //1d
if(xianshi_c3.3){$        led_6        out,low;}                //3d
xianshi_yanshi();
/**************************************************/                //第二种
$                led_1                in;
$                led_2                out,high;
$                led_3                in;
$                led_4                in;
$                led_5                in;
$                led_6                in;
if(xianshi_c1.0){$        led_1        out,low;}                //1a
//if(){$        led_2        out,low;}
if(xianshi_c2.5){$        led_3        out,low;}                //2f
if(xianshi_c2.6){$        led_4        out,low;}                //2g
if(xianshi_c2.2){$        led_5        out,low;}                //2c
//if(){$        led_6        out,low;}                //无
xianshi_yanshi();
/**************************************************/                //第三种
$                led_1                in;
$                led_2                in;
$                led_3                out,high;
$                led_4                in;
$                led_5                in;
$                led_6                in;

if(xianshi_c1.1){$        led_1        out,low;}                //1b
if(xianshi_c2.0){$        led_2        out,low;}                //2a
//if(){$        led_3        out,low;}
if(xianshi_c3.5){$        led_4        out,low;}                //3f
if(xianshi_c3.6){$        led_5        out,low;}                //3g
if(xianshi_c3.4){$        led_6        out,low;}                //3e
xianshi_yanshi();
/**************************************************/                //第四种
$                led_1                in;
$                led_2                in;
$                led_3                in;
$                led_4                out,high;
$                led_5                in;
$                led_6                in;
if(xianshi_c1.4){$        led_1        out,low;}                //1e
if(xianshi_c2.1){$        led_2        out,low;}                //2b
//if(){$        led_3        out,low;}                                //无
//if(){$        led_4        out,low;}
if(xianshi_c3.0){$        led_5        out,low;}                //3a
//if(){$        led_6        out,low;}                                //无
xianshi_yanshi();
/**************************************************/                //第五种
$                led_1                in;
$                led_2                in;
$                led_3                in;
$                led_4                in;
$                led_5                out,high;
$                led_6                in;
//if(){$        led_1        out,low;}                //无
if(xianshi_c2.4){$        led_2        out,low;}                //2e
if(xianshi_c3.1){$        led_3        out,low;}                //3b
if(xianshi_c3.2){$        led_4        out,low;}                //3c
//if(){$        led_5        out,low;}
//if(){$        led_6        out,low;}                                //无
xianshi_yanshi();
/**************************************************/                //第六种
$                led_1                in;
$                led_2                in;
$                led_3                in;
$                led_4                in;
$                led_5                in;
$                led_6                out,high;
//if(){$        led_1        out,low;}                //1h
if(xianshi_c2.3){$        led_2        out,low;}                //2d
//if(){$        led_3        out,low;}                //2h
//if(){$        led_4        out,low;}                //3h
//if(){$        led_5        out,low;}                //无
//if(){$        led_6        out,low;}
xianshi_yanshi();
}
/****************************************************************************************************/
void                xianshi_jisuan()                //显示计算
{
word                        xianshi_aa1;
$                led_1                in;                //消隐
$                led_2                in;
$                led_3                in;
$                led_4                in;
$                led_5                in;
$                led_6                in;
xianshi_aa1                =xianshi_a1;
xianshi_b1                =0;                //百位
xianshi_b2                =0;                //十位
xianshi_b3                =0;                //个位


while(xianshi_aa1>99)                //百位的计算
{
xianshi_aa1                -=100;
xianshi_b1                +=1;
}

while(xianshi_aa1>9)                //十位的计算
{
xianshi_aa1                -=10;
xianshi_b2                +=1;
}

xianshi_b3                =xianshi_aa1;                //个位


xianshi_qumo_a1                =xianshi_b1;                //百位取模
xianshi_qumo();
xianshi_c1                        =xianshi_qumo_a1;

xianshi_qumo_a1                =xianshi_b2;                //十位取模
xianshi_qumo();
xianshi_c2                        =xianshi_qumo_a1;

xianshi_qumo_a1                =xianshi_b3;                //个位取模
xianshi_qumo();
xianshi_c3                        =xianshi_qumo_a1;
}
/****************************************************************************************************/
//共阴:0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f//0x77,0x7c,0x39,0x5e,0x79,0x71
void                xianshi_qumo()                        //显示取模
{
if(xianshi_qumo_a1 ==0x00){xianshi_qumo_a1 =0x3f; return;}                //0
if(xianshi_qumo_a1 ==0x01){xianshi_qumo_a1 =0x06; return;}                //1
if(xianshi_qumo_a1 ==0x02){xianshi_qumo_a1 =0x5b; return;}                //2
if(xianshi_qumo_a1 ==0x03){xianshi_qumo_a1 =0x4f; return;}                //3
if(xianshi_qumo_a1 ==0x04){xianshi_qumo_a1 =0x66; return;}                //4
if(xianshi_qumo_a1 ==0x05){xianshi_qumo_a1 =0x6d; return;}                //5
if(xianshi_qumo_a1 ==0x06){xianshi_qumo_a1 =0x7d; return;}                //6
if(xianshi_qumo_a1 ==0x07){xianshi_qumo_a1 =0x07; return;}                //7
if(xianshi_qumo_a1 ==0x08){xianshi_qumo_a1 =0x7f; return;}                //8
if(xianshi_qumo_a1 ==0x09){xianshi_qumo_a1 =0x6f; return;}                //9

if(xianshi_qumo_a1 ==0x0a){xianshi_qumo_a1 =0x77; return;}                //a
if(xianshi_qumo_a1 ==0x0b){xianshi_qumo_a1 =0x7c; return;}                //b
if(xianshi_qumo_a1 ==0x0c){xianshi_qumo_a1 =0x39; return;}                //c
if(xianshi_qumo_a1 ==0x0d){xianshi_qumo_a1 =0x5e; return;}                //d
if(xianshi_qumo_a1 ==0x0e){xianshi_qumo_a1 =0x79; return;}                //e
if(xianshi_qumo_a1 ==0x0f){xianshi_qumo_a1 =0x71; return;}                //f
}
/****************************************************************************************************/
void                xianshi_yanshi()                //显示延时
{
.delay 1900;
}
/****************************************************************************************************/
/****************************************************************************************************/

PFC460.rar

15.95 KB

使用特权

评论回复

相关帖子

发新帖
您需要登录后才可以回帖 登录 | 注册

本版积分规则

284

主题

441

帖子

55

粉丝