Modify your design of assignment a1 by feeding back the FA outputs into the MSP4
ID: 2079309 • Letter: M
Question
Modify your design of assignment a1 by feeding back the FA outputs into the MSP430. Modify your software to compare the actual FA outputs with the expected outputs. If actual and expected outputs differ, the program should stop to show the bad I/O combination and turn on an error indicator. The program should resume following the FA truth table once the difference in outputs disappears. This assignment is due on Wednesday February 1"at the beginning of class. Submit a hard copy of you source code and your implementation of your assignment to demonstrate its function at the beginning of class. Your implementation should start running as soon as it gets powered up with a USB power SourceExplanation / Answer
#include <msp430.h>
int main(void) //main function starts
{
WDTCTL=WDTPW+WDTHOLD; //Stop watchdog timer
P1DIR|=0x07; //Intializing P1.0=Cin,P1.1=B,P1.2=A as output pins
P2DIR|=0x07; //Intializing P2.0=error led as output pins connect indicating led to this pin
volatile int out[8]={0,1,1,2,1,2,2,3}; //desired output array for the given input
for(;;) //loop runs for infinite time
{
volatile 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
while(P6IN!=out[i]) //connect P6.0 to sum and P6.1 to Cout checking for correct opertion
{
P2OUT=1; //if there is error led will on and program will be in this untill error rectified
}
P2OUT=0; //removing the signal to error led
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
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.