/**********************************************************************
**
** 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;
}
Previous article:MSP430F249ADC
Next article:Getting Started with MSP430F249GPIO Control
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- pyboard receives serial port data conversion problem
- Notepad Editor - Verilog Code Snippets and Syntax Checker
- [ESK32-360 Review] + Getting to know the ESK32-360 development board
- TI-83 Premium CE Python Edition Calculator
- Improved support for CAN in the STM32 branch of mpy
- The secret of the longevity of the wireless earbud charging case is that it consumes only 1.6% of power per month
- NMOS application solution!
- EEWORLD University Hall----Achieving a new generation of test and measurement applications
- Keil common errors/warnings and solutions
- Editor's Recommendation: A must-read for FPGA newbies!