Talk:MSP430 Launchpad Shift Register

Comments on MSP430 Launchpad Shift Register -

Lwangaman said ...
As for the idea of supporting multiple chained shift registers, one step further in this direction is simply separating the latch on / latch off logic from the shiftOut function. I created two separate functions "latchOn" and "latchOff", so that if I have let's say three daisy chained shift registers, I just have to latchOff, shiftOut three times, then latchOn. Here is my code:

// set latch off to enable Shifting bits in void latchOff( void ) {   //Set latch to low (should be already) P1OUT &= ~LATCH; } // set latch on to set bits in output void latchOn( void ) {    // Pulse the latch pin to write the values into the storage register P1OUT |= LATCH; P1OUT &= ~LATCH; } // Take the given 8-bit value and shift it out, LSB to MSB void shiftOut(unsigned char val) {  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; } }

As for the rest I pretty much kept it as is... In this way I can simply do something like this:

latchOff; shiftOut(0x80); shiftOut(0x01); latchOn;

And here is a youtube video demonstrating 5 daisy-chained M74HC595B Shift Registers hooked up to the MSP430 Launchpad controlling 40 leds with only three wires. In this specific example I also hooked up 5 ULN2803s (darlington transistor arrays) so that I can add two more sets of 40 leds to the load.

--Lwangaman 07:45, 5 August 2012 (CDT)