//本人实际用过的 15 级联 595驱动代码 部分现在已经改成 3级 绝对好用
sbit LCD_CS = P5^4; //74HC595 片选
sbit LCD_DAT = P5^5; //74HC595 数据
sbit LCD_CLK = P3^3; //74HC595 时钟
sbit LCD_OE = P1^4; //74HC595输出使能
unsigned char LED_code[3]; //显示缓冲
/*----------------------------
LED驱动---74HC595 3个级联
-----------------------------*/
void LCD_send_data(void) //LED驱动
{
unsigned char tmp = 0 , i = 0, dat = 0;
LCD_CS = 0; //关输出
delay_us(2); //延时
for( tmp = 0; tmp <= 2; tmp ++)
{
dat = LCD_code[tmp];//======待显示数据
for(i = 0; i <= 7; i ++)
{
LCD_CLK = 0;
delay_us(2); //延时
if( (dat & 0x80) == 0x80)
LCD_DAT = 1;
else
LCD_DAT = 0;
dat <<= 1;
delay_us(2); //延时
LCD_CLK = 1;
delay_us(2); //延时
}
}
LCD_CS = 1; //开输出
}
//
|