您现在的位置: 主页 > MCU > 单片机技术应用 > MSP430F249数码管显示 -
本文所属标签:
为本文创立个标签吧:

MSP430F249数码管显示 -

来源: 网络用户发布,如有版权联系网管删除 2018-09-06 

[导读]
/******************************************************************** ** File : Display.c | Display led segment | ** Version : 1.0 ** Descrip

 

本文引用地址: http://www.21ic.com/app/mcu/201804/765860.htm

/******************************************************************
**
** 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


/***设置数码管显示****/


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




uchar const Segment1[]={0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f}; //不带小数点编码
uchar const Segment2[]={0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78, 0x00, 0x10}; //带小数点编码




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; //关狗

P4DIR = 0XFF; //P4设置为输出,位码控制
P4SEL = 0;

P5DIR = 0XFF; //P5设置为输出,断码控制
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;


}

 



              查看评论 回复



嵌入式交流网主页 > MCU > 单片机技术应用 > MSP430F249数码管显示 -
 

"MSP430F249数码管显示 -"的相关文章

网站地图

围观()