#include"bsp.h"
sbit DUAN = P0^0;
sbit WEI = P0^1;
unsigned char TABLECA[16] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
unsigned char TABLECC[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
unsigned char TABLE[8] = {0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f};
unsigned char SHOW[8] = {0x00};
void bsp_sega(unsigned int i)
{
P1 = TABLECA[i];
}
void bsp_segb()
{
static unsigned char i = 0;
P1 = 0x00;//除影
DUAN = 1;
DUAN = 0;
P1 = TABLE[i];
WEI = 1;
WEI = 0; //位扫描
P1 = SHOW[i]; //显示
DUAN = 1;
DUAN = 0;
P1 = TABLE[i]; //位扫描
WEI = 1;
WEI = 0;
i++;
if (i == 8)
{
i = 0;
}
}
//除影
DUAN = 1;
DUAN = 0;
P1 = TABLE[i];
WEI = 1;
WEI = 0; //位扫描
P1 = SHOW[i]; //显示
DUAN = 1;
DUAN = 0;
P1 = TABLE[i]; //位扫描
WEI = 1;
WEI = 0;
i++;
if (i == 8)
{
i = 0;
}
}
单片机数码管的动态扫描的基本原理就是快速的扫描每一位7段数码管,使显示的结果看上去是一直显示的。