Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Shift register Hc595

Status
Not open for further replies.

alimemory

Junior Member level 1
Joined
Jun 19, 2014
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Location
Nigeria
Activity points
119
Hi all
Can any help me with code
How to #define shift register
Using microc pro
I want get more outputs
thanks.
 

Code:
// connect 74HC595 reset to +5v, output enable to ground

char Dout = 0x55;            // Data to shift to 74HC595
int i;

sbit Data  at PORTB.B0;     // pin 14 74HC595   Serial Data input
sbit Sc_cp at PORTB.B1;   // pin 11 74HC595   Shift clock
sbit Tc_cp at PORTB.B2;   // pin 12 74HC595   Latch clock

void shift_out( char dat )
{
Tc_cp = 0;                // set latch clock to 0
for( i = 0; i < 8; i ++ )
  {
  Sc_cp = 0;              // set shift clock to 0
  Data = 0;                 //  set Data to 0
  if( (dat & 0x80) == 0x80)   // check if bit 7 is a 1
    Data = 1;               // if bit 7 is a 1, set Data to 1
  dat = (dat << 1);      // shift Data out bit 7 first
  Sc_cp= 1;               // clock Data into shift register
  }  
Tc_cp = 1;                // clock Data in shift register to 74HC595's outputs
}


void main()
{
  TRISB = 0x00;           // Configure PORTB as outputs
  shift_out(Dout);          // send 0x55 to 74HC595
  while(1){}
}
 

Hi,

HC595 is discussed many times in this forum. Did you search for it?

Klaus
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top