1。功能说明:按下按钮,数码管从0计数,到9复位为0,继续显示。
2。代码如下:欢迎大家优化为最佳代码。
/*
Date : 20091010
For : button drive led
Tool : HT IDE 3000 V7.0
MCU : HT48R50A-1
Fsys : 4MHz
ASM/C: C
VPM : yes
*/
#include "self-HT48R50A-1.h"
//for Segs-Com0
#define SegsPort _pa
#define SegsCtrl _pac
#define PtrPort _pb6
#define PtrCtrl _pbc6
#define Com0Port _pb7
#define Com0Ctrl _pbc7
//for Button
#define swPort _pc0 //switch port
#define swCtrl _pcc0 //switch controlling
//variable
int iCntButton;
//function
int getSwitchStatus(void);
void blinkSegs(int);
//the main function
void main(void)
{
int i;
SegsPort = 0x00; //turn off segs
SegsCtrl = 0x00; //output
Com0Ctrl = 0;
PtrCtrl = 0;
Com0Port = 0;
PtrPort = 0;