台湾应广单片机PMS152程序瘦身后显示0-59每秒加1
https://bbs.21ic.com/blog-818997-683484.html
PMS152程序瘦身后显示0-59
Compile ...
C:\Users\su\Desktop\第二课准备\闪烁\闪烁.PRE
C:\Users\su\Desktop\第二课准备\闪烁\闪烁.C
Link ...
memory 0x48 ~ 0x4F for stack, vector = 0x0
memory 0x0 ~ 0x47 are free
Check Sum is 0xA91196
PMS152 : ROM Size : 0x4E6
PMS152 : Last use Code : 0x12A , Remain Free-Code : 0x3BC [+35] , Remain Free-RAM : 66
0 error(s), 0 warning(s)
#include "extern.h"
/**************************************************/
bit led_a : pb.0;
bit led_b : pb.1;
bit led_c : pb.2;
bit led_d : pb.3;
bit led_e : pb.4;
bit led_f : pb.5;
bit led_g : pb.6;
bit led_zuo : pa.0;
bit led_you : pa.4;
bit led_gg : pb.7;
bit led_shuchu : pa.5;
bit iic_sda : pb.2;
bit iic_scl : pb.3;
/**************************************************/
void xianshi(); //显示
void xianshi_fenjie(); //显示分解
byte xianshi_a1,xianshi_a2;
//byte xianshi_b1,xianshi_b2;
//xianshi_a1显示的数值/xianshi_a2传递用
//byte xianshi_b1,十位/xianshi_b2,个位
/**************************************************/
//bit iic_sda : pb.2; //iic
//bit iic_scl : pb.3;
//pbph.2 =1; //iic上拉电阻
//pbph.3 =1; //iic上拉电阻
/**************************************************/
void yanshi(); //延时
byte yanshi_a1;
/**************************************************/
byte a1;
/**************************************************/
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
xianshi_a1 =0;
xianshi_a2 =0;
led_gg =1;
led_shuchu =1;
pbph.2 =1; //iic上拉电阻
pbph.3 =1; //iic上拉电阻
pac =0b1111_1111;
pbc =0xff;
/**************************************************/
tm2c |=0b0001_0000; //timer2控制寄存器//系统时钟定周期模式
tm2s =0b0110_0000; //timer2分频寄存器//64
tm2ct =0; //timer2计数寄存器
tm2b =0xfa; //timer2上限寄存器//分频64//250次1秒
inten.6 =1; //启用timer2中断
//intrq.6 =0; //timer2中断请求
engint; //启用全局中断
//disgint; //停用全局中断
/**************************************************/
while (1)
{
xianshi();
}
}
/**************************************************/
void xianshi() //显示
{
byte xianshi_b1,xianshi_b2;
pb |=0x7f; //清屏
xianshi_b1=xianshi_a1;
xianshi_b2=0;
while(xianshi_b1>=10) //十位
{
xianshi_b2++;
xianshi_b1 -=10;
}
//b1; //个位
led_zuo=1;
led_you=0;
xianshi_a2 =xianshi_b2;
xianshi_fenjie();
yanshi_a1=160; yanshi(); //95,100HZ/130,75HZ/160,60HZ
pb |=0x7f; //清屏
led_zuo=0;
led_you=1;
xianshi_a2 =xianshi_b1;
xianshi_fenjie();
yanshi_a1=160; yanshi();
}
/**************************************************/
void xianshi_fenjie() //显示分解
{
if(xianshi_a2==0)
{
pb &=0b1100_0000; //0
return;
}
if(xianshi_a2==1)
{
pb &=0b1111_1001; //1
return;
}
if(xianshi_a2==2)
{
pb &=0b1010_0100; //2
return;
}
if(xianshi_a2==3)
{
pb &=0b1011_0000; //3
return;
}
if(xianshi_a2==4)
{
pb &=0b1001_1001; //4
return;
}
if(xianshi_a2==5)
{
pb &=0b1001_0010; //5
return;
}
if(xianshi_a2==6)
{
pb &=0b1000_0010; //6
return;
}
if(xianshi_a2==7)
{
pb &=0b1111_1000; //7
return;
}
if(xianshi_a2==8)
{
pb &=0b1000_0000; //8
return;
}
if(xianshi_a2==9)
{
pb &=0b1001_0000; //9
return;
}
}
/**************************************************/
void yanshi() //延时
{
while(yanshi_a1)
{
yanshi_a1--;
.delay(200);
}
}
/**************************************************/
void interrupt()
{
pushaf;
intrq =0;
a1++;
if(a1==250) //1秒
{
a1=0;
xianshi_a1++;
if(xianshi_a1==60)
{
xianshi_a1=0;
}
}
popaf;
}
/**************************************************/ |