IC解密74hc595使用方法与单片机驱动源程序
- IC解密#include<reg52.h>
- IC解密#include<intrins.h>
- typedef unsigned char u8;
- typedef unsigned int u16;
- sbit SH_CP1 = P2^1;
- sbit DS = P2^0;
- sbit ST_CP1 = P2^2;
- sbit SH_CP2 = P2^3;
- sbit ST_CP2 = P2^4;
- void delay() //延时函数
- {
- u8 a, b, c;
- for(a = 0; a < 110; ++a)
- for(b = 0; b < 110; ++b)
- for(c = 0; c < 10; ++c);
- }
- void send_data_74hc595(u16 data_74hc595) //传送数据给74hc595
- {
- u8 a;
- for(a = 0; a < 8; ++a)
- {
- DS = (data_74hc595 << a) & 0x80; //从高位开始传输
- SH_CP1 = 0;
- SH_CP2 = 0;
- _nop_();
- _nop_();
- SH_CP1 = 1;
- SH_CP2 = 1;
- }
- }
- void show_74hc595() //数据显示
- {
- ST_CP1 = 0;
- ST_CP2 = 0;
- _nop_();
- _nop_();
- ST_CP1 = 1;
- ST_CP2 = 1;
- }
- void main()
- {
- while(1)
- {
- send_data_74hc595(0x00); //依次传输数据,上面的数据传输给第二个595
- send_data_74hc595(0x01); //下面的给第一个·595
- show_74hc595(); //数据显示
- delay(); //延时
- send_data_74hc595(0x00);
- send_data_74hc595(0x03);
- show_74hc595();
- delay();
- send_data_74hc595(0x00);
- send_data_74hc595(0x07);
- show_74hc595();
- delay();
- send_data_74hc595(0x00);
- send_data_74hc595(0x0f);
- show_74hc595();
- delay();
- send_data_74hc595(0x00);
- send_data_74hc595(0x1f);
- show_74hc595();
- delay();
- send_data_74hc595(0x00);
- send_data_74hc595(0x3f);
- show_74hc595();
- delay();
- send_data_74hc595(0x00);
- send_data_74hc595(0x7f);
- show_74hc595();
- delay();
- send_data_74hc595(0x00);
- send_data_74hc595(0xff);
- show_74hc595();
- delay();
- send_data_74hc595(0x01);
- send_data_74hc595(0xff);
- show_74hc595();
- delay();
- send_data_74hc595(0x03);
- send_data_74hc595(0xff);
- show_74hc595();
- delay();
- send_data_74hc595(0x07);
- send_data_74hc595(0xff);
- show_74hc595();
- delay();
- send_data_74hc595(0x0f);
- send_data_74hc595(0xff);
- show_74hc595();
- delay();
- send_data_74hc595(0x1f);
- send_data_74hc595(0xff);
- show_74hc595();
- delay();
- send_data_74hc595(0x3f);
- send_data_74hc595(0xff);
- show_74hc595();
- delay();
- send_data_74hc595(0x7f);
- send_data_74hc595(0xff);
- show_74hc595();
- delay();
- send_data_74hc595(0xff);
- send_data_74hc595(0xff);
- show_74hc595();
- delay();
- }
- }
上一篇:IC解密电子罗盘原理

芯片解密