74HC595程序应用(原理图)
/* 输入输出在主函数里*/#include<reg52.h>
//#include<intrins.h> /*_nop_()在<intrins.h>里*/
#define uchar unsigned char
#define uintunsigned int
sbit shcp=P2^0;
sbit ds=P2^1;
sbit stcp=P2^2;
uchar temp;
uchar code duan[]=
{0xc0,0xf9,0xa4,0xb0,0x99,
0x92,0x82,0xf8,0x80,0x10};
/*延时*/
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=100;y>0;y--);
}
/*数据输入 */
void input(uchar temp)
{
uchar i;
for(i=0;i<8;i++) /*只是表明向左移动 移动过次*/
{
temp<<=1;
ds=CY;
shcp=0;
shcp=1;
//_nop_();
//_nop_();
}
}
/*数据输出*/
void output()
{
stcp=0;
//_nop_();
stcp=1;
// _nop_();
//stcp=0;
}
/*主函数*/
void main(void)
{
uchar i;
while(1)
{
for(i=0;i<10;i++)
{
temp=duan;
input(temp);
output();
delay(300);
}
}
}
感谢分享~感觉可以不用intrins.h
自己写个循环左移好了
省点ROM是一点 兰斯洛 发表于 2013-5-15 17:22 static/image/common/back.gif
感谢分享~感觉可以不用intrins.h
自己写个循环左移好了
省点ROM是一点
是的 intrins.h 只是没删 谢谢 不错,不错 学习了,谢过 第一次使用,标记!
页:
[1]