ADD A LOT OF COMMENTS!!!! The code is used to add two binary numbers The circuit
ID: 2079267 • Letter: A
Question
ADD A LOT OF COMMENTS!!!! The code is used to add two binary numbers The circuit has an xor gate, or gate & and gate . First three leds are A B and Cin and next two are Cout and SumCan someone please add comments to the code and explain what each part does, and re write the code to be more efficient!! If their is another way to write the code. Please do so but make it very similar. Needs to be in "C" #include Kmsp430.h int main(void) WDTCTL WDTPW WDTHOLD; Stop watchdog timer P1DIR I 0x07 Set P1.0 to output direction for (R) volatile unsigned int i,j; for (i eix8 itt. P10UT i; Toggle P1.0 using exclusive-OR for return
Explanation / Answer
#include <msp430.h>
int main(void) //main function starts
{
WDTCTL=WDTPW+WDTHOLD; //Stop watchdog timer
P1DIR|=0x07; //Intializing P1.0,P1.1,P1.2 as output pins
for(;;) //loop runs for infinite time
{
voltaile unsigned int i,j; //i,j are variables for further loop iteration
for(i=0;i<8;i++) //loop repeats for 8 times from i=0 to 7
{
P1OUT=i; //assaigning i value to port P1OUT
for(j=0;j<50000;j++) //creates delay, can change the delay time by changing 50000 to other value accordingly
{
}
}
}
return(0); //returns null value
}
this code is the simple and optimal for the application;
If you are having any doubts just comment
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.