| 各位好 我在调试三位数码管的时候单个单个显示数字没有问题,如下程序。
 #include<pic.h>
 #define uchar unsigned char
 #define uint unsigned int
 __CONFIG(0x3B31);
 const uchar table[]={0xfd,0xfb,0xf7};
 const uchar smg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//共阳数码管
 void delay_ms(uint ms)
 {
 uint x,y;
 for(x=ms;ms>0;ms--)
 {
 for(y=66;y>0;y--);
 }
 }
 void PORT_init(void)
 {
 TRISB=0;//B口输出模式
 TRISD=0;//D口低三位为输出模式
 }
 
 void display(void)
 {
 uchar i;
 for(i=0;i<3;i++)
 {
 PORTD=table[i];//位选
 PORTB=smg[i];//段选
 delay_ms(1000);
 }
 }
 
 }
 void main()
 {
 delay_ms(1);
 PORT_init();
 while(1)
 {
 display();
 }
 }
 但是当我把三个位都选中的时候三个数码管不会动了,一直都是0
 如下程序
 #include<pic.h>
 #define uchar unsigned char
 #define uint unsigned int
 __CONFIG(0x3B31);
 const uchar table[]={0xfd,0xfb,0xf7};
 const uchar smg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//共阳数码管
 void delay_ms(uint ms)
 {
 uint x,y;
 for(x=ms;ms>0;ms--)
 {
 for(y=66;y>0;y--);
 }
 }
 void PORT_init(void)
 {
 TRISB=0;//B口输出模式
 TRISD=0;//D口低三位为输出模式
 }
 
 void display(void)
 {
 uchar i;
 for(i=0;i<10;i++)
 {
 PORTD=0x00;//位选全打开
 PORTB=smg[i];//段选
 delay_ms(1000);
 }
 }
 
 }
 void main()
 {
 delay_ms(1);
 PORT_init();
 while(1)
 {
 display();
 }
 }
 请问是什么问题呢???
 |