|
|
本菜鸡大三,目前在做单片机设计,三个课题,其中一个是实现路口红绿灯,但是我遇到的问题是我的数码管显示不正常,现象是开始仿真后看不见数码管显示的数字,只有按下暂停才会显示代码我也没找到问题,数码管采用共阳极接法,在proteus中的型号名称为7SEG-MPX8-CA,第一个图片就可以看作是proteus开始仿真的实时效果,,第二个图片是按下暂停时的效果,关于数码管部分我想达到的效果是第三个图里数字时钟的那种显示效果,关于数码管显示的代码如下,求大佬指点一二,
#include <regx52.h>
#include <INTRINS.H>
#include "tim.h"
void delay(uchar xms);
void shumashow(uchar location,uchar number);
void display();
void displays(void);
uchar button=0;
uchar code shuma[10]={0x88,0xbb,0xc1,0x91,0xb2,0x94,0x04,0xb9,0x80,0x90};
void main(){
while(1){
displays();
}
}
/*
数码管显示
*/
void displays(void){
shumashow(1,1);delay(1);
shumashow(2,2);delay(1);
shumashow(3,3);delay(1);
shumashow(4,4);delay(1);
shumashow(5,5);delay(1);
shumashow(6,6);delay(1);
shumashow(7,7);delay(1);
shumashow(8,8);delay(1);
}
void shumashow(uchar location,uchar number){
switch(location){
case 1: P1_0=0; P1_1=0;P1_2=0;break;
case 2: P1_0=0; P1_1=0;P1_2=1;break;
case 3: P1_0=0; P1_1=1;P1_2=0;break;
case 4: P1_0=0; P1_1=1;P1_2=1;break;
case 5: P1_0=1; P1_1=0;P1_2=0;break;
case 6: P1_0=1; P1_1=0;P1_2=1;break;
case 7: P1_0=1; P1_1=1;P1_2=0;break;
case 8: P1_0=1; P1_1=1;P1_2=1;break;
}
P0=shuma[number];
}
void delay(uchar xms){
uchar i,j;
while(xms){
i=2;
j=239;
do{
while(--j);
}while(--i);
xms--;
}
}
|
|