CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

74597 Driver

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

74597 Driver
PostPosted: Thu Jan 25, 2007 4:55 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group