两个SN74HC595级联控制数码管的程序
SRCLK和Rclk上升沿需要延时吗?
/*******74HC595发送数据******/
void Send_595(uchar dat) //发送一个字节
{
uchar i,j;
uchar m;
P_HC595_SRCLK = 0;
m = dat;
for(i=0; i<8; i++)
{
P_HC595_SRCLK = 0; //上升沿移位
if(m&0x80==0x80) P_HC595_SER = 1; //最高位D7开始直至最低位D0
else P_HC595_SER = 0;
P_HC595_SRCLK = 1;
m<<=1;
}
}
void send_595out() //595数据并出
{
P_HC595_RCLK = 0;
P_HC595_RCLK = 1;
}
主程序while(1)里面嵌入
{
Send_595(0x0f);
delay_ms(1);
Send_595(0xf0);
send_595out();
}
实际595发出的是0x01,程序哪里不对呢? |