Sign in

username:

password:



Not a member?

Search avrclub



Search tips

Subscribe to avrclub



avrclub by Keywords

AT90S2313 | AT90S8515 | ATMega | ATmega128 | ECL | FETS | IAR | Keyboard | LCD | STK50 | TMOS | UART

Ads

Discussion Groups

Discussion Groups | AVRclub | Using shift registers 74hc595,74hc164,74hc165

Atmel AVR Microcontroller discussion group.

Using shift registers 74hc595,74hc164,74hc165 - donfrisky1 - Jun 3 17:29:00 2003

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




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )


Re: [AVR club] Using shift registers 74hc595,74hc164,74hc165 - Brian Sidebotham - Jun 4 4:57:00 2003

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=dat & 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




(You need to be a member of avrclub -- send a blank email to avrclub-subscribe@yahoogroups.com )