This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How can i use a 74HC597 Shift Register?

Other Parts Discussed in Thread: MSP430G2553, ENERGIA

Hi!

 

I try to use a shift Register. The one i have is a 74HC597 from ti. The examples are all based on the 595 Version that is different.

I found a Tutorial that Shows how to use it with Arduino, but i can not transfer this to the MSP430.

The Thing i read in this tutorial is that there is a fourth pin (PL in the data sheet) that shifts the Information from the middle Register to the shift Register.

The Datasheet itself does not tell me what to do (that means i do not found something that helped me).

 

Can someone explain what to do?

Here is the original ti sample code with my added LOAD pin, what seems to be wrong but i really dont know how to use ist. Where do i have to pulse the LOAD pin?

 

//***************************************************************************************

// MSP430 Driver for 74HC595 Shift Register

//

// Description; Drives 8 LED's with 3 digital pins of the MSP430, via a shift register

//

// MSP430x2xx

//

//***************************************************************************************

#include

<msp430g2553.h>

//Define our pins

#define

DATA BIT0 // DS -> 1.0

#define

CLOCK BIT4 // SH_CP -> 1.4

#define

LATCH BIT5 // ST_CP -> 1.5

#define

ENABLE BIT6 // OE -> 1.6

#define

LOAD BIT3  //  PL -> 1.3  

// The OE pin can be tied directly to ground, but controlling

// it from the MCU lets you turn off the entire array without

// zeroing the register

// Declare functions

void

delay ( unsigned int );

void

pulseClock ( void );

void

shiftOut ( unsigned char );

void

enable ( void );

void

disable ( void );

void

init ( void );

void

pinWrite ( unsigned int, unsigned char );

 

int

main( void )

{

 

// Stop watchdog timer to prevent time out reset

  WDTCTL = WDTPW + WDTHOLD;

  P1DIR |= (DATA + CLOCK + LATCH + ENABLE + LOAD); 

// Setup pins as outputs

  enable();

// Enable output (pull OE low)

 

int i;

 

//Do a "ping-pong" effect back and forth

 

for(;;){

   

for ( i = 0 ; i < 8 ; i++ ){

      shiftOut(1 << i);

    delay(50);

    }

   

for ( i = 7 ; i >= 0 ; i-- ){

      shiftOut(1 << i);

    delay(50);

    }

  }

}

// Delays by the specified Milliseconds

// thanks to:

// http://www.threadabort.com/archive/2010/09/05/msp430-delay-function-like-the-arduino.aspx

void

delay(unsigned int ms)

{

while (ms--)

    {

        __delay_cycles(1000);

// set for 16Mhz change it to 1000 for 1 Mhz

    }

}

// Writes a value to the specified bitmask/pin. Use built in defines

// when calling this, as the shiftOut() function does.

// All nonzero values are treated as "high" and zero is "low"

void

pinWrite( unsigned int bit, unsigned char val )

{

 

if (val){

    P1OUT |= bit;

  }

else {

    P1OUT &= ~bit;

  }

}

// Pulse the clock pin

void

pulseClock( void )

{

  P1OUT |= CLOCK;

  P1OUT ^= CLOCK;

}

// Take the given 8-bit value and shift it out, LSB to MSB

void

shiftOut(unsigned char val)

{

 

//Set latch to low (should be already)

  P1OUT &= ~LATCH;

 

char i;

 

// Iterate over each bit, set data pin, and pulse the clock to send it

 

// to the shift register

 

for (i = 0; i < 8; i++)  {

      pinWrite(DATA, (val & (1 << i)));

      pulseClock();

  }

 

// Pulse the latch pin to write the values into the storage register

  P1OUT |= LATCH;

  P1OUT &= ~LATCH;

  P1OUT |= LOAD;

  P1OUT &= ~LOAD;

}

// These functions are just a shortcut to turn on and off the array of

// LED's when you have the enable pin tied to the MCU. Entirely optional.

void

enable( void )

{

  P1OUT &= ~ENABLE;

}

void

disable( void )

{

  P1OUT |= ENABLE;

}

 

Thank You!

 

Kind Regards, Steffen

  • I think i found my mistake. Could it be that i only bought the wrong Shift Registers? As i understand the 597 are for Input only. Could this be right?

     

    Edit: Yes it is right. The 74HC579 is for Input and the 75HC595 is for Output.

  • I think for your application a good old serial in parallel out 8-bit shift register will do the job. The 8-bit latch is not needed. Thus you only need 2 port pins of the MSP430 to drive it, serial-data and clock. The only difference is during the shifting, the LEDs will "blink", but that will only last for a few micro-seconds and the human eye will not be able to tell the difference.

    Of course, the data and clock must be compatible with the 3V port pins of the MSP430, and the parallel out must be able to drive the LEDs.

    For shifting data, you may use the SPI capability of MSP430, or you can simply use bit banging.

  • Steffen Müller said:
    Edit: Yes it is right. The 74HC579 is for Input and the 75HC595 is for Output.

    Well, it depends as what oyu define input and outnout. Of course both have input and output. However, the 579 has a parallel input and serial output, while the 595 has a serial inpu tand serial/parallel output.

    Which one is 'for input' or 'for output' depends on usage. You can use the the 579 to output SPI serial data by using a parallel port to stuff it. Or you can use the 595 to have an additional 8 bit output port by stuffing it with the MSPs hardware SPI (or any three port pins).

  • Thank you both. I am not understanding the full MSP430. SPI is one thing i have not used yet. I have also not understand yet how i2c works for example (not needed for this shift Register Project).
    I have ordered 595 Shift Registers after checking that the 597 is not the right one for me.
    For me it is very difficult to understand all the datasheet and Family guide Information, but i learned that it is the key for using microcontrollers.
    I like the MSP430, and i like to use CCS instead of Energia. It might take a lot of time, but Energia and the Arduino IDE for the Atmel MCs too hides what is really Happening in the MC itself. I want to understand what the things do. I am glad that you give me hints what other possibilities i have with the 597 and the Problem itself.

  • Steffen Müller said:
    For me it is very difficult to understand all the datasheet and Family guide Information, but i learned that it is the key for using microcontrollers.

    Not for MCUs in general, but for the whole MSP series. On othe rMCUs, you have everything in one datasheet. But when you migrate to a different MCU of the same family, you'll have a new, separate datasheet, and it is very difficult to figure what's identical, similar or different.
    On MSP, the uers guide will cover everything that' sidentical and also show up differences, while the datasheet covers the specific capabilities of a specific MCU. And the errata sheet tells where an MCU differs from the users guide unintentionally, due to silicon errors.

    It's difficult to learn when you start with MSPs, but makes life much easier when you have multiple projects with different MSPs - or want to migrate a project to a bigger MCU.

**Attention** This is a public forum