0% found this document useful (0 votes)
445 views7 pages

Lunch Box Switch - Seven Segment Display (CC and CA) : Lab Activity - 7

Uploaded by

Vaibhav Goel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
445 views7 pages

Lunch Box Switch - Seven Segment Display (CC and CA) : Lab Activity - 7

Uploaded by

Vaibhav Goel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

LAB ACTIVITY – 7

Lunch Box Switch - Seven Segment display


(CC and CA)

Institute of Engineering and Technology


JK Lakshmipat University, Jaipur

SUBMITTED TO
Dr. Hanuman Prasad Agarwal
Dr. Devika Kataria

SUBMITTED BY
Shruti Jain
2020BTechCSE071

Date: 20-06-2021
AIM:-
a) To get introduced with Switch Segment Common Cathode display with MSP430.
b) To get introduced with Switch Segment Common Anode display with MSP430.

SIMULATOR USED:

Code Composer Studio:- Code Composer Studio™ software is an integrated


development environment (IDE) that supports TI's microcontroller (MCU) and
embedded processor portfolios. Code Composer Studio software comprises a suite of
tools used to develop and debug embedded applications. The software includes an
optimizing C/C++ compiler, source code editor, project build environment, debugger,
profiler and many other features. The intuitive IDE provides a single-user interface that
takes you through each step of the application development flow. Familiar tools and
interfaces let you get started faster than ever before. Code Composer Studio software
combines the advantages of the Eclipse software framework with advanced embedded-
debug capabilities from TI resulting in a compelling feature-rich development
environment for embedded developers.

MSP430:- The MSP430 is a 16-bit microcontroller that has a number of special


features not commonly available with other microcontrollers: Complete system on-a-
chip — includes LCD control, ADC, I/O ports, ROM, RAM, basic timer, watchdog
timer, UART, etc. Extremely low power consumption — only 4.2 nW per instruction,
typical High speed — 300 ns per instruction @ 3.3 MHz clock, in register and register
addressing mode RISC structure — 27 core instructions Orthogonal architecture (any
instruction with any addressing mode) Seven addressing modes for the source
operand Four addressing modes for the destination operand Constant generator for
the most often used constants (–1, 0, 1, 2, 4, 8) Only one external crystal required —
a frequency locked loop (FLL) oscillator derives all internal clocks Full real-time
capability — stable, nominal system clock frequency is available after only six clocks
when the MSP430 is restored from low-power mode (LPM) 3; — no waiting for the
main crystal to begin oscillation and stabilize The 27 core instructions combined with
these special features make it easy to program the MSP430 in assembler or in C, and
provide exceptional flexibility and functionality. For example, even with a relatively low
instruction count of 27, the MSP430 is capable of emulating almost the complete
instruction set of the legendary .
CIRCUIT DIAGRAM:
For Common Cathode display

For Common Anode display


CODE
For Common Cathode display

#include <msp430.h>
#define SW BIT3 // Switch -> P2.3
// Define Pin Mapping of 7-segment Display
// Segments are connected to P1.0 - P1.7
#define SEG_A BIT0
#define SEG_B BIT1
#define SEG_C BIT2
#define SEG_D BIT3
#define SEG_E BIT4
#define SEG_F BIT5
#define SEG_G BIT6
#define SEG_DP BIT7
// Define each digit according to truth table
#define D0 (SEG_A + SEG_B + SEG_C + SEG_D + SEG_E + SEG_F)
#define D1 (SEG_B + SEG_C)
#define D2 (SEG_A + SEG_B + SEG_D + SEG_E + SEG_G)
#define D3 (SEG_A + SEG_B + SEG_C + SEG_D + SEG_G)
#define D4 (SEG_B + SEG_C + SEG_F + SEG_G)
#define D5 (SEG_A + SEG_C + SEG_D + SEG_F + SEG_G)
#define D6 (SEG_A + SEG_C + SEG_D + SEG_E + SEG_F + SEG_G)
#define D7 (SEG_A + SEG_B + SEG_C)
#define D8 (SEG_A + SEG_B + SEG_C + SEG_D + SEG_E + SEG_F + SEG_G)
#define D9 (SEG_A + SEG_B + SEG_C + SEG_D + SEG_F + SEG_G)
#define DA (SEG_A + SEG_B + SEG_C + SEG_E + SEG_F + SEG_G)
#define DB (SEG_C + SEG_D + SEG_E + SEG_F + SEG_G)
#define DC (SEG_A + SEG_D + SEG_E + SEG_F)
#define DD (SEG_B + SEG_C + SEG_D + SEG_E + SEG_G)
#define DE (SEG_A + SEG_D + SEG_E + SEG_F + SEG_G)
#define DF (SEG_A + SEG_E + SEG_F + SEG_G)
// Define mask value for all digit segments except DP
#define DMASK ~(SEG_A + SEG_B + SEG_C + SEG_D + SEG_E + SEG_F + SEG_G)
// Store digits in array for display
const unsigned int digits[16] = {D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, DA,
DB, DC, DD, DE, DF};
volatile unsigned int i = 0;
/*@brief entry point for the code*/
void main(void) {
WDTCTL = WDTPW | WDTHOLD; //! Stop Watch dog (Not recommended for
code in production and devices working in field)
// Initialize 7-segment pins as Output
P1DIR |= (SEG_A + SEG_B + SEG_C + SEG_D + SEG_E+ SEG_F + SEG_G + SEG_DP);
P2DIR &= ~SW; // Set SW pin -> Input
while(1) {
if(!(P2IN & SW)) // If SW is Pressed
{
delay_cycles(200000); //Delay to avoid Switch Bounce
while(!(P2IN & SW)); // Wait till SW Released
i++; //Increment count
if(i>15)
{i=0;
}
}
P1OUT = (P1OUT & DMASK) + digits[i]; // Display current digit for CC
}
}
For Common Anode display

#include <msp430.h>
#define SW BIT3 // Switch -> P2.3
// Define Pin Mapping of 7-segment Display
// Segments are connected to P1.0 - P1.7
#define SEG_A BIT0
#define SEG_B BIT1
#define SEG_C BIT2
#define SEG_D BIT3
#define SEG_E BIT4
#define SEG_F BIT5
#define SEG_G BIT6
#define SEG_DP BIT7
// Define each digit according to truth table
#define D0 (SEG_A + SEG_B + SEG_C + SEG_D + SEG_E + SEG_F)
#define D1 (SEG_B + SEG_C)
#define D2 (SEG_A + SEG_B + SEG_D + SEG_E + SEG_G)
#define D3 (SEG_A + SEG_B + SEG_C + SEG_D + SEG_G)
#define D4 (SEG_B + SEG_C + SEG_F + SEG_G)
#define D5 (SEG_A + SEG_C + SEG_D + SEG_F + SEG_G)
#define D6 (SEG_A + SEG_C + SEG_D + SEG_E + SEG_F + SEG_G)
#define D7 (SEG_A + SEG_B + SEG_C)
#define D8 (SEG_A + SEG_B + SEG_C + SEG_D + SEG_E + SEG_F + SEG_G)
#define D9 (SEG_A + SEG_B + SEG_C + SEG_D + SEG_F + SEG_G)
#define DA (SEG_A + SEG_B + SEG_C + SEG_E + SEG_F + SEG_G)
#define DB (SEG_C + SEG_D + SEG_E + SEG_F + SEG_G)
#define DC (SEG_A + SEG_D + SEG_E + SEG_F)
#define DD (SEG_B + SEG_C + SEG_D + SEG_E + SEG_G)
#define DE (SEG_A + SEG_D + SEG_E + SEG_F + SEG_G)
#define DF (SEG_A + SEG_E + SEG_F + SEG_G)
// Define mask value for all digit segments except DP
#define DMASK ~(SEG_A + SEG_B + SEG_C + SEG_D + SEG_E + SEG_F + SEG_G)
// Store digits in array for display
const unsigned int digits[16] = {D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, DA,
DB, DC, DD, DE, DF};
volatile unsigned int i = 0;
/*@brief entry point for the code*/
void main(void) {
WDTCTL = WDTPW | WDTHOLD; //! Stop Watch dog (Not recommended for
code in production and devices working in field)
// Initialize 7-segment pins as Output
P1DIR |= (SEG_A + SEG_B + SEG_C + SEG_D + SEG_E+ SEG_F + SEG_G + SEG_DP);
P2DIR &= ~SW; // Set SW pin -> Input
while(1)
{ if(!(P2IN & SW)) // If SW is Pressed
{
delay_cycles(200000); //Delay to avoid Switch Bounce
while(!(P2IN & SW)); // Wait till SW Released
i++; //Increment count
if(i>15)
{ i=0;
}
}

P1OUT = ~((P1OUT & DMASK) + digits[i]); // Display current digit for CA

}
}
PHOTOGRAPH OF PROJECT
For Common Cathode display

For Common Anode display


DISCUSSION
We need to always check the COM-Port Number before Building the project and make sure
power LED is Glowing.
In Case “A” after Building the project on MSP430 the Common Cathode Display shows “0”
and when we press the switch on project board then the Number on display changes.
Hexadecimal numbers from “0” to “F” are displayed on the Display.
In Case “B” we changed connection of common pins of Display to Power and after Building
the project on MSP430 the Common Anode Display shows “0” and when we press the switch
on project board then the Number on display changes. Hexadecimal numbers from “0” to “F”
are displayed on the Display.
For both the display circuit we should press the switch gently and toggle it slowly to avoid
switch bouncing.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy