MSP430F249 digital tube display

Publisher:画意人生Latest update time:2017-11-25 Source: eefocusKeywords:MSP430F249 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/**********************************************************************
**                                                       
** File : Display.c | Display led segment |                                    
** Version : 1.0     
** Description: led 7 segment display                                                                         
** Author : LightWu                              
** Date : 2013-4-9                                                       
**                                                   
*******************************************************************/


#include "MSP430x24x.h"


#define uint unsigned int
#define uchar unsigned char


/***Set the digital tube display****/


#define L1_OFF P4OUT|=BIT0 //Turn off L1
#define L1_NO P4OUT&=~BIT0 //Light up L1
#define L2_OFF P4OUT|=BIT1 //Turn off L2
#define L2_NO P4OUT&=~BIT1 //Light up L2
#define L3_OFF P4OUT|=BIT2 //Turn off L3
#define L3_NO P4OUT&=~BIT2 //Light up L3
#define L4_OFF P4OUT|=BIT3 //Turn off L4
#define L4_NO P4OUT&=~BIT3 //Light up 4
#define L5_OFF P4OUT|=BIT4 //
Turn off L5 #define L5_NO P4OUT&=~BIT4 //Light up L5
#define L6_OFF P4OUT|=BIT5 //Turn off L6
#define L6_NO P4OUT&=~BIT5 //Light up L6
#define L7_OFF P4OUT|=BIT6 //Turn off L7
#define L7_NO P4OUT&=~BIT6 //Light up L7
#define L8_OFF P4OUT|=BIT7 //Turn off L8
#define L8_NO P4OUT&=~BIT7 //Light up L8




uchar const Segment1[]={0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f}; //uchar without decimal point
encoding const Segment2[]={0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78, 0x00, 0x10}; //with decimal point encoding




void Display( uchar num1, uchar num2, uchar num3, uchar num4, uchar num5, uchar num6, uchar num7, uchar num8);


void Delay(void)
{
  uint m;
  for(m=1000;m>0;m--);
}


void main(void)
{
        // Stop watchdog timer to prevent time out reset
        WDTCTL = WDTPW + WDTHOLD; //shut down the watchdog
  
        P4DIR = 0XFF; //P4 is set as output, bit code control
        P4SEL = 0;
        
        P5DIR = 0XFF; //P5 is set as output, break code control
        P5SEL = 0;
        
        while(1)
        {
        // volatile unsigned int i;


        // i = 50000; // Delay
        // do (i--);
        // while (i != 0);
            
            Display(1,2,3,4,5,6,7,8);
        }
        


}


void Display( uchar num1, uchar num2, uchar num3, uchar num4, uchar num5, uchar num6, uchar num7, uchar num8)
{
    P5OUT = Segment1[ num1 ];//
    L1_NO;
    Delay();
    L1_OFF;
    
    P5OUT = Segment1[ num2 ];//
    L2_NO;
    Delay();
    L2_OFF;
    
    P5OUT = Segment1[ num3 ];//
    L3_NO;
    Delay();
    L3_OFF;
    
    P5OUT = Segment1[ num4 ];//
    L4_NO;
    Delay();
    L4_OFF;
    
    P5OUT = Segment1[ num5 ];//
    L5_NO;
    Delay();
    L5_OFF;
    
    P5OUT = Segment1[ num6 ];//
    L6_NO;
    Delay();
    L6_OFF;
    
    P5OUT = Segment1[ num7 ];//
    L7_NO;
    Delay();
    L7_OFF;
    
    P5OUT = Segment1[ num8 ];//
    L8_NO;
    Delay();
    L8_OFF;


}

Keywords:MSP430F249 Reference address:MSP430F249 digital tube display

Previous article:MSP430F249ADC
Next article:Getting Started with MSP430F249GPIO Control

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号