//功能:6位数码管动态扫描
#include
__CONFIG(0x3f32);
//================================================//
#define uchar unsigned char
uchar SMBL;
const uchar LED7[]={0x92,0x99,0xb0,0xa4,0xf9,0xc0};
//=================函数声明======================//
void main(void) //主函数
{
TRISA=0X00; //A口输出
TRISD=0X00; //B口输出
PORTA=0XFE; //A口输出高
ADCON1=0X07; //关A口AD
GIE=1; //开总中断
TMR0IE=1; //开定时器中断
OPTION=0X02; //设分频比
TMR0=0X00; //定时器赋初值
T0IF=0; //定时器中断标志置0
SMBL=0;
while(1) //循环
{
PORTD=LED7[SMBL];
}
}
//=======数码管动态显示01235中断显示函数=========//
void interrupt dsq(void)
{
T0IF=0; //清定时器中断标志
PORTD=0XFF; //熄灭数码管
asm("bsf status,0"); //请C标志位
asm("rlf porta,f"); //A口左移
if(++SMBL>=7) //数显变量+1,≠7跳过
{
PORTA=0B11111110;
SMBL=0;
}
TMR0=0X00; //定时器赋值
}