RobG 1,892 Posted December 7, 2010 Share Posted December 7, 2010 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. SugarAddict and bluehash 2 Quote Link to post Share on other sites
NatureTM 100 Posted December 7, 2010 Share Posted December 7, 2010 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. Quote Link to post Share on other sites
bluehash 1,581 Posted December 7, 2010 Share Posted December 7, 2010 Welcome to the forums Rob G. Thanks for submitting. Remember, there is this. Quote Link to post Share on other sites
RobG 1,892 Posted December 7, 2010 Author Share Posted December 7, 2010 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 NatureTM 1 Quote Link to post Share on other sites
NatureTM 100 Posted December 7, 2010 Share Posted December 7, 2010 I'm more of a coder, but I like your schematic. What program do you use? Quote Link to post Share on other sites
RobG 1,892 Posted December 7, 2010 Author Share Posted December 7, 2010 EAGLE for Mac NatureTM 1 Quote Link to post Share on other sites
GeekDoc 226 Posted December 7, 2010 Share Posted December 7, 2010 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. NatureTM 1 Quote Link to post Share on other sites
Mike 0 Posted December 13, 2010 Share Posted December 13, 2010 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. Quote Link to post Share on other sites
rivalslayer 0 Posted December 13, 2010 Share Posted December 13, 2010 Nice project. Can be be used to extend output capabilities. Thanks for sharing...! Quote Link to post Share on other sites
RobG 1,892 Posted December 13, 2010 Author Share Posted December 13, 2010 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. sirri 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.