问下为什么这段代码在multisim下不能运行
我是在KEIL中写代码生成HEX之后放到multisim中。这是让共阳极数码管显示的程序
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
unsigned char code table[]={
0x40,0xcf,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10
};
uchar num;
void main()
{
P2=0x80;
P0=0xcf;
while(1);
}
这样就可以显示为1
但是如果改代码为
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
unsigned char code table[]={
0x40,0xcf,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10
};
uchar num;
void main()
{
P2=0x80;
P0=table;
while(1);
}
区别就在P0处用数组赋值就不行,为什么? PO和数码管间用锁存器接通,但是去掉锁存器第二段代码就可以是数码管点亮
页:
[1]