?以下编写了两种管脚名和对应说明
#define HC595_NUM (5)
#define OE_H OE = 1
#define OE_L OE = 0
#define STCP_H STCP = 1
#define STCP_L STCP = 0
#define SHCP_H SHCP = 1
#define SHCP_L SHCP = 0
//sbit HC595Rclk =P1^3; //RCLK
//sbit HC595Clk =P1^4; //SRCLK
//sbit HC595In =P1^2; //SER
sbit OE = P3^3;
sbit DS = P3^2; //串行数据输入 对应SER
sbit STCP = P3^4; //锁存寄存器时钟输入 对应RCLK
sbit SHCP = P3^5; //移位寄存器时钟输入 对应SRCLK
void Hc595_Write_data(unsigned char Data[HC595_NUM]);
/*移位寄存器的上升沿*/
static void Shift_rising_edge(void){
SHCP_L, SHCP_H; //上升沿传输数据到寄存器
}
/*锁存寄存器上升沿*/
static void LOCK_rising_edge(void){
STCP_L, STCP_H; //上升沿传输数据到寄存器
}
static void Wirte_byte(unsigned char Data, void(*SRE)(void)){
unsigned char i=0;
for(i=0;i<8;i++){
DS =(Data<<i)&0x80 ? 1:0;
SRE();
}
}
void Hc595_Write_data(unsigned char Data[HC595_NUM]){
unsigned char j;
for(j=0;j<HC595_NUM;j++){
Wirte_byte(Data[j],Shift_rising_edge);
}
LOCK_rising_edge();
}
?
?