Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
74597 Driver |
Posted: Thu Jan 25, 2007 4:55 pm |
|
|
Code: |
/////////////////////////////////////////////////////////////////////////
//// 74597.C ////
//// ////
//// Driver for 74**597 8 Bit Shift Register with input latches ////
//// ////
//// void init_597( ) ////
//// Must be called once in the initializacion. ////
//// ////
//// int get_597_In( ) ////
//// Return the 8 parallel input data. ////
//// ////
//// ////
//// Autor: Humberto ////
//// ////
/////////////////////////////////////////////////////////////////////////
//
//-----------------------------------------------------------------------
//
// 74**597 8 Bit Shift Register with input latches
//
// PIN nomenclature used in the code is as follows:
//
// PIN OUT
// ___ ___
// | |
// Q1-| |- Vcc < = INPUTS
// Q2-| |- Q0
// Q3-| <|- PIN14 SER
// Q4-| <|- PIN13 SLOAD
// Q5-| <|- PIN12 RCK
// Q6-| <|- PIN11 SCK
// Q7-| <|- PIN10 SCLR
// Gnd-| >|- PIN9 Qout
// |________|
//
//---------------------------------------------------------------------
void init_597()
{
output_low(SCLR); // activate reset
delay_us(10); //
output_low(SCK); // idle level
output_low(RCK); // idle level
output_high(SLOAD); // select serial
output_high(SCLR); // deactivate reset
}
//---------------------------------------------------------------------
int get_597_In()
{
int8 i, value;
output_high(RCK); // Data loaded to input latches
delay_us(10);
output_low(RCK); // Freeze inputs
delay_us(10);
output_low(SLOAD); // Data transfer from input latch to
delay_us(10); // shift registers
output_high(SLOAD);
for(i=1; i<=8; i++) // Clock-in while collecting bits...
{
shift_left(&value,1,input(Qout));
output_high(SCK); // going up clock pulse
delay_us(10);
output_low(SCK); // recover idle level
}
return(value);
}
//-------------------------------------------------------------------
|
Humberto |
|