Reply by Brian Sidebotham June 4, 20032003-06-04
pretty simple:

//
############################################################################
###
// ##### delay_595()
##
// ##### Generates a small time delay so the 74595 can keep up
##
// ##### ##
//
############################################################################
### void delay_595(void)
{
unsigned char p;
p=0;
while(p != 5)
{
p++;
}
} //
############################################################################
###
// ##### toggle_595_clk()
##
// ##### This routine clocks the 595, the data in the 595 will be shifted
along ##
// ##### and the current data on the input pin will be sifted in
##
//
############################################################################
###

void toggle_595_clk(void)
{
PORTD.0=1;
delay_595();

PORTD.0=0;
delay_595();
} //
############################################################################
###
// ##### init_595()
##
// ##### This routine initialises the 595 by clearing it, ready for new data
##
// ##### ##
//
############################################################################
###

void init_595(void)
{
PORTA.7=0; // init 595
PORTD.0=0;
delay_595();
}
//
############################################################################
###
// ##### out_595(unsigned char dat)
##
// ##### This routine loads the 74595 with the byte 'dat'
##
// ##### ##
//
############################################################################
###

void out_595(unsigned char dat)
{
unsigned char p;

init_595();

p=0x80;
while(p>0x00)
{
PORTB.3 & p;
toggle_595_clk();
p>>=1;
}
// data is now loaded into 595;
PORTA.7=1; // output data on latch
} ----- Original Message -----
From: "donfrisky1" <gtw@gtw@...>
To: <avrclub@avrc...>
Sent: Tuesday, June 03, 2003 10:29 PM
Subject: [AVR club] Using shift registers 74hc595,74hc164,74hc165 > Hi
> Is anyone have a routines to shift-out data to a 74hc595. Or shift-
> in to a 74hc164 or 74hc165. I want to use 3 wire method with the
> AT90S2313 AVR. I'm using AVRAssembler. Maybe you can post to files area.
> Thank you
> Don




Reply by donfrisky1 June 3, 20032003-06-03
Hi
Is anyone have a routines to shift-out data to a 74hc595. Or shift-
in to a 74hc164 or 74hc165. I want to use 3 wire method with the
AT90S2313 AVR. I'm using AVRAssembler. Maybe you can post to files area.
Thank you
Don