Jump to content
RobG

MSP430 LaunchPad, 74HC595, 16 LEDs

Recommended Posts

What is it?

4 digit BCD counter using LaunchPad and two 74HC595 shift registers.

 

Note: One important thing that I forgot to add is that since I am powering this from LP, I am using here 74HC595 and not HCT.

LP provides 3.6V, HCT needs 5V.

 

See it in action:

 

#include 

unsigned int counter = 0;                   // Counter variable

void main(void)
{
 WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

 P1OUT |= 0x01; 							// Port P1.0 will be used to latch
 P1DIR |= 0x01;

 USICTL0 |= USIPE6 + USIPE5 + USIMST + USIOE; // Out & clk enable, SPI Master
 USICTL1 |= USICKPH + USIIE;               // Counter interrupt
 USICKCTL = USIDIV_7 + USISSEL_2;          // /2 SMCLK
 USICTL0 &= ~USISWRST;                     // Enable USI
 USICNT = USI16B;                     		// Enable 16 bit

 CCTL0 = CCIE;                             // CCR0 interrupt enabled
 CCR0 = 10000;								// Duration
 TACTL = TASSEL_2 + MC_1 + ID_3;           // SMCLK, upmode

 _bis_SR_register(LPM0_bits + GIE);                 // Enter LPM0 w/ interrupt
}

// Timer A0 interrupt service routine
#pragma vector = TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
 counter = _bcd_add_short(counter, 0x01);	// Decimally increase counter's value  
 USISR = counter;							
 USICNT |= 16;                           	// Start USI
}

// USI interrupt service routine
#pragma vector = USI_VECTOR
__interrupt void USI_TXRX (void)
{
 USICTL1 &= ~USIIFG;               		// Clear pending flag
 P1OUT &= ~0x01;							// Latch data
 P1OUT |= 0x01;
}


 

In the coming parts, I will be increasing the number of digits to 8 and changing LEDs to 7-segment displays, maybe throw in a keyboard.

post-197-13513549335_thumb.png

Share this post


Link to post
Share on other sites

Hey RobG, welcome to the forums. I've been playing around with that same shift register and the Launchpad recently to drive a 7-segment as part of a guitar tuner project. I'm looking forward to more updates.

Share this post


Link to post
Share on other sites
Hey RobG, welcome to the forums. I've been playing around with that same shift register and the Launchpad recently to drive a 7-segment as part of a guitar tuner project. I'm looking forward to more updates.

 

This is schematic for Part 2:

 

Moved to another post

Share this post


Link to post
Share on other sites

Looks like EagleCAD. The free version is quite useful (get the SparkFun parts library!). The only limits are the PCB size and layers (2), which are fine for almost anything you will want.

 

If you end up sending your design for professional boards, I recommend dorkbotPDX. Great price, and awesome quality. Also, he'll take your Eagle file, so you don't have to produce individual Gerber files. :D

Share this post


Link to post
Share on other sites

Hi Rob,

may i ask what Vcc you're using, and what current you drive the LEDs with?

I've read elsewhere the 74HC595 is designed for relatively low currents only, that's why i'm asking.

Share this post


Link to post
Share on other sites
Hi Rob,

may i ask what Vcc you're using, and what current you drive the LEDs with?

I've read elsewhere the 74HC595 is designed for relatively low currents only, that's why i'm asking.

 

Hi,

I am powering it directly from LaunchPad, so it's about 3.6V.

I am using 330ohm resistors to limit the current to about 5mA.

74HCT595 can source/sink up to 35mA.

 

One more thing, I am using HC series, not HCT, sorry for the confusion.

 

Rob.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...