#include <iom16v.h>
#include <macros.h>
#define uchar unsigned char
#define uint unsigned int
#pragma interrupt_handler miao:9
int num=0;
uint num2=0;
static int z=0;
/************************************************
*********************************************
下面为数码管驱动
程序
*************************************************
*********************************************/
//数码管为公阴极
const uchar table[10] =
{0xd7,0x11,0xcd,0x5d,0x1b,0x5e,0xde,0x15,0xdf,0x5f,};
const uchar q[4] = {0xef,0xdf,0xbf,0x7f};//个十百千的位选信号
uchar p[4] = {0,0,0,0};//暂存
//uint fre=1234;
//把要显示的数存入暂存区
void process(unsigned int i)
{
p[0] = i/1000;
i = i%1000;
p[1] = i/100;
i = i%100;
p[2] = i/10;
i = i%10;
p[3] = i;
}
//显示函数
void display (void)
{
uchar i;
for(i=0;i<4;i++)
{
PORTA= q[i];//位选,共阴
PORTB = table[p[i]];
delay_nms(1);
}
}
void displayT (void)
{
uchar i;
for(i=0;i<4;i++)
{
- 1
- 2
前往页