Driving two digits seven segment indication with MSP430 Launchpad

This example is Step1 from the Clock Project I’ve just started. Here you can see how to drive dynamically two digits seven segment indication using only one controller. I’m using MSP430G2231 controller.

Coming soon the documentation of the project from this step. Schematic, BOM, video and source code. Presently the analog part of the project is not so as perfect as should be, because I started it with all the components available in my Bag-Full-Of-Parts. The MSP430 Launchpad board is wired to a breadboard.
This is the a video showing the prototype.

Code is below.

#include "msp430g2231.h"

void delay_ms(unsigned int ms )
{
    unsigned int i;
    for (i = 0; i<= ms; i++)
    __delay_cycles(500); 
}

void light_number(int position_number)
{
	switch (position_number)
	{
		case 10:    
		P1OUT = 0x88;
		break;    
		case 20:
	    P1OUT = 0x08;    
		break;
		case 11:
	    P1OUT = 0xfc;
		break;
		case 21:
	    P1OUT = 0x7c;
		break;
		case 12:
	    P1OUT = 0xa2;
		break;
		case 22:
	    P1OUT = 0x22;
		break;
		case 13:
	    P1OUT = 0xe0;
		break;
		case 23:
	    P1OUT = 0x60;
		break;
		case 14:
	    P1OUT = 0xd4;
		break;
		case 24:
	    P1OUT = 0x54;
		break;
		case 15:
	    P1OUT = 0xc1;
		break;
		case 25:
	    P1OUT = 0x41;
		break;
		case 16:
	    P1OUT = 0x81;
		break;
		case 26:
	    P1OUT = 0x01;
		break;
		case 17:
	    P1OUT = 0xf8;
		break;
		case 27:
	    P1OUT = 0x78;
		break;
		case 18:
	    P1OUT = 0x80;
		break;
		case 28:
	    P1OUT = 0x00;
		break;
		case 19:
	    P1OUT = 0xc0;
		break;
		case 29:
	    P1OUT = 0x40;
		break;	
		default: break;
	}
}

int main( void )
{
    WDTCTL = WDTPW + WDTHOLD; // Disable Watchdog Timer
    BCSCTL1 = CALBC1_1MHZ;    // Set range
    DCOCTL = CALDCO_1MHZ;     // Set DCO step + modulation
    P1DIR = 0xff;             // P1.X output

    while(1)
    {
    	int cnt=0;
    	do{
    		int number1 = cnt/10;
    		int number2 = cnt%10;
    		int cnt2 = 0;
    		do{
    			light_number(20+(number2));
    			delay_ms(10);
    			light_number(10+(number1));
    			delay_ms(10);
    			cnt2++;
    		}while(cnt2<30);
    		
    		cnt++;
    	}while(cnt<100);
	}
} 

5 thoughts on “Driving two digits seven segment indication with MSP430 Launchpad

  1. disculpa podrias explicarme el codigo casi no le entiendo y no se programar mucho soy estudiante de prepa y quisiera que me lo explicaras estoy descubriendo poco a poco este microcontrolador

  2. I need the schematic,could you add schematic ?
    I think MSP430G2553 can run this code without any trouble.Am I right ?

  3. Good one! but it may occupy more GPIO lines. But in MSP430 all I/O are multi-purpose – so wastage of functionality.
    But by using BCD to 7-seg decoder – then you save three pins.

    My question is – Can we drive the MSP430 IC alone, without using the Launch pad board. If so what voltage should we provide to that.

Leave a Reply

Your email address will not be published. Required fields are marked *

*