Question

Can you help me to find the error on my code please is for micro procesador...

Can you help me to find the error on my code please

is for micro procesador msp430

is to control a bdc 7-segment

#include "msp430g2231.h"

int a = BIT0; //P1_0 -> Segment A

int b = BIT1; //P1_1 -> Segment B

int c = BIT2; //P1_2 -> Segment C

int d = BIT3; //P1_3 -> Segment D

int e = BIT4; //P1_4 -> Segment E

int f = BIT5; //P1_5 -> Segment F

int g = BIT6; //P1_6 -> Segment G

void delay(void);

void main(void)

{

unsigned int timeperiod; //Will be used to change timing on digits

P1DIR |= a; // Set P1.0 to output direction

P1DIR |= b; // Set P1.1 to output direction

P1DIR |= c; // Set P1.2 to output direction

P1DIR |= d; // Set P1.3 to output direction

P1DIR |= e; // Set P1.4 to output direction

P1DIR |= f; // Set P1.5 to output direction

P1DIR |= g; // Set P1.6 to output direction

P1OUT = 0x0000; //All segments OFF

while(1)

{

P1OUT &= ~(a + b + c + d + e + f + g); //Makes sure all segments are off

switch(Val)

{

case(0): //Num-0

P1OUT |= a + b + c + d + e + f;

P1OUT &= ~(a + b + c + d + e + f);

break;

case(1): //Num-1

P1OUT |= b + c;

break;

case(2): //Num-2

P1OUT |= a + b + d + e + g;

break;

case(3): //Num-3

P1OUT |= a + b + c + d + g;

break;

case(4): //Num-4

P1OUT |= b + c + f + g;

break;

case(5): //Num-5

P1OUT |= a + c + d + f + g;

break;

case(6): //Num-6

P1OUT |= a + c + d + e + f + g;

break;

case(7): //Num-7

P1OUT |= a + b + c;

break;

case(8): //Num-8

P1OUT |= a + b + c + d + e + f + g;

break;

case(9): //Num-9

P1OUT |= a + b + c + d + f + g;

break;

}

P2OUT |= BIT0; //Set P2_0-> Buzzer ON

Delay();

P2OUT ~= BIT0; //Reset P2_0-> Buzzer OFF

}

  

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include "msp430g2231.h"

int a = BIT0; //P1_0 -> Segment A

int b = BIT1; //P1_1 -> Segment B

int c = BIT2; //P1_2 -> Segment C

int d = BIT3; //P1_3 -> Segment D

int e = BIT4; //P1_4 -> Segment E

int f = BIT5; //P1_5 -> Segment F

int g = BIT6; //P1_6 -> Segment G

void delay(void);

void main(void)

{

unsigned int timeperiod; //Will be used to change timing on digits

P1DIR |= a; // Set P1.0 to output direction

P1DIR |= b; // Set P1.1 to output direction

P1DIR |= c; // Set P1.2 to output direction

P1DIR |= d; // Set P1.3 to output direction

P1DIR |= e; // Set P1.4 to output direction

P1DIR |= f; // Set P1.5 to output direction

P1DIR |= g; // Set P1.6 to output direction

P1OUT = 0x0000; //All segments OFF

while(1)

{

P1OUT &= ~(a + b + c + d + e + f + g); //Makes sure all segments are off

switch(Val)

{

case(0): //Num-0

P1OUT |= a + b + c + d + e + f;

P1OUT &= ~(a + b + c + d + e + f);

break;

case(1): //Num-1

P1OUT |= b + c;

break;

case(2): //Num-2

P1OUT |= a + b + d + e + g;

break;

case(3): //Num-3

P1OUT |= a + b + c + d + g;

break;

case(4): //Num-4

P1OUT |= b + c + f + g;

break;

case(5): //Num-5

P1OUT |= a + c + d + f + g;

break;

case(6): //Num-6

P1OUT |= a + c + d + e + f + g;

break;

case(7): //Num-7

P1OUT |= a + b + c;

break;

case(8): //Num-8

P1OUT |= a + b + c + d + e + f + g;

break;

case(9): //Num-9

P1OUT |= a + b + c + d + f + g;

break;

}

P2OUT |= BIT0; //Set P2_0-> Buzzer ON

Delay();

P2OUT ~= BIT0; //Reset P2_0-> Buzzer OFF

}

  

}

Add a comment
Know the answer?
Add Answer to:
Can you help me to find the error on my code please is for micro procesador...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Help modify below code using the timer Timer_A to toggle two LEDs in periodic time intervals...

    Help modify below code using the timer Timer_A to toggle two LEDs in periodic time intervals of A)10 sec B)30 sec C)1 sec the original code toggled red LED when an overflow occured: #include <ms430.h> #define RedLED BIT0 #define RedLEDToggle (P1OUT ^= RedLED) void main (void) { WDTCTL = WDTPW|WDTHOLD; P1DIR = RedLED; P1OUT = RedLED; TECTL = TASSEL_2|ID_3|MC_3|TAIE; TACCR0 = 62500; _enable_interrupts(); LPM1;       //enter low power mode } #pragma vector=TIMER_A1_VECTOR __interrupt void Timer_A(void) { switch(TAIV) { case 0x02:...

  • Program is for an Arduino 1. Add the letters “A”, “b”, “c”, “d”, “E”, “F” to...

    Program is for an Arduino 1. Add the letters “A”, “b”, “c”, “d”, “E”, “F” to your homework program. Continually display “0123”, “4567”, “89Ab”, “cdEF” with a one second delay between each one. HINT: Expand pickNumber() to use numbers 10-15 (a-f in hex). Create new functions for a-f. (THIS IS THE CODE FROM THE HOMEWORK) /*************************************** name:Stopwatch function: you can see the number increases by one per second on the 4-digit 7-segment display. ***********************************/ //Email:[email protected] //Website:www.sunfounder.com /**************************************/ #include //the pins...

  • Can some help me with my code I'm not sure why its not working. Thanks In...

    Can some help me with my code I'm not sure why its not working. Thanks In this exercise, you are to modify the Classify Numbers programming example in this chapter. As written, the program inputs the data from the standard input device (keyboard) and outputs the results on the standard output device (screen). The program can process only 20 numbers. Rewrite the program to incorporate the following requirements: a. Data to the program is input from a file of an...

  • Code in C++: Please help me fix the error in function: void write_account(); //function to write...

    Code in C++: Please help me fix the error in function: void write_account(); //function to write record in binary file (NOTE: I able to store data to a txt file but however the data get error when I try to add on data the second time) void display_all(); //function to display all account details (NOTE: This function is to display all the info that save account.txt which is ID, Name, and Type) void modify_account(int); //function to modify record of file...

  • Can someone please help me. i keep getting an error in my code. I need it...

    Can someone please help me. i keep getting an error in my code. I need it to be on three seperate files! attached is my assignment and my code. c++ The class date Type implements the date in a program. Write the class functions as specified in the UML class diagram. The values for the month, day, and year should be validated (in the class functions) before storing the date into the data members. Set the invalid member data to...

  • can someone please double check my code here are the requirements please help me fulfill the...

    can someone please double check my code here are the requirements please help me fulfill the requirements Using the material in the textbook (NumberList) as a sample, design your own dynamic linked list class (using pointers) to hold a series of capital letters. The class should have the following member functions: append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges...

  • please help me asap 1 Determine the output for the following code: #include<stdio.h> int main static...

    please help me asap 1 Determine the output for the following code: #include<stdio.h> int main static int num; fornum : ++ num: num++) -- printf("%d". num): if num ==8) break; [10] COI retum 1 b) #include<stdio.h> int main int test: fortest - 0: tests=5: test); printer test: retum

  • C++ Object Oriented assignment Can you please check the program written below if it has appropriately...

    C++ Object Oriented assignment Can you please check the program written below if it has appropriately fulfilled the instructions provided below. Please do the necessary change that this program may need. I am expecting to get a full credit for this assignment so put your effort to correct and help the program have the most efficient algorithm within the scope of the instruction given. INSTRUCTIONS Create a fraction class and add your Name to the name fraction and use this...

  • Please help to resolve my error. This Java code is supposed to evaluate one line equation...

    Please help to resolve my error. This Java code is supposed to evaluate one line equation of the form X Operator =Z where X is any name of a variable and Y and Z are integers By user in equation solver window. Currently the code executes expressions such as Y Operator(+,-,*,/) Z package Equations; /** * This program evaluates arithmetic expressions */ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.StringTokenizer; public class EquationSolver extends JFrame implements ActionListener { private JTextField...

  • please help me to creating UML class diagrams. Snake.java package graphichal2; import java.awt.Color; import java.awt.Font; import...

    please help me to creating UML class diagrams. Snake.java package graphichal2; import java.awt.Color; import java.awt.Font; import java.awt.Frame; import java.awt.Graphics; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Random; enum Dir{L, U, R, D}; class Food { public static int FOODSTYLE = 1; private int m = r.nextInt(Yard.WIDTH / Yard.B_WIDTH); private int n = r.nextInt(Yard.HEIGHT / Yard.B_WIDTH - 30/Yard.B_WIDTH) + 30/Yard.B_WIDTH;// 竖格 public static Random r = new Random(); public int getM() { return m; } public void setM(int m)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT