从坛上复制的74HC595程序仿真不显示?请帮我看看,谢谢!
单片机源程序如下:
#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit ds_595 =P2^0; //串行数据输入
sbit b_cp_595 =P2^2; //输出锁存器控制脉冲 st_cp_595
sbit a_cp_595 =P2^1; //串行移位时钟脉冲 sh_cp_595
extern uchar datas[6]; //存放6个数码管的显示数字
uchar ledcode[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
// 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
void delay(uint z)
{
uint t1,y;
for(t1=z;t1>0;t1--)
for(y=110;y>0;y--);
}
void led_display(void)
{
uchar i,j;
bit testb;
uchar movebit[6];
uchar test;
for(i=0;i<6;i++) //选中数码管
movebit[ i]=ledcode[datas[ i]];
delay(1);
for(i=0;i<6;i++) //数据移位
{
test=movebit[ i];
for(j=0;j<8;j++)
{
testb=test&0x80;
test=test<<1;
if(testb)
{
ds_595=1;
}
else
{
ds_595=0;
}
a_cp_595=1;
a_cp_595=0;
} //数据移位
}
b_cp_595=0;
b_cp_595=1;
b_cp_595=0;
}
void main()
{
led_display();
while (1);
} |