Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So I have a microprocessors class that neither the professor nor the TA has real

ID: 3664650 • Letter: S

Question

So I have a microprocessors class that neither the professor nor the TA has really gone into detail about how to go about these questions, they sort of just gave them to us and expect us to finish them. Me being an EE, I'm finding trouble writing programs in C. I'm not looking for a handout, if you could help me out by guiding me in the right direction, that would be very helpful. The question is:

1.Write a C program that sets a counter to zero and goes into a loop where the counter is incremented by 10000. If the result of the sum is greater than 61000 set the counter to zero. Then copy the result to P1OUT.

The code that I have done so far is:

#include <msp430g2553.h>

/*

* main.c

*/

int main(void) {

WDTCTL = WDTPW | WDTHOLD;   // Stop watchdog timer

   int i;

  

   i=0;

       for ( i = 0; i < 61000; i+=10000 );

           if (i > 61000)

           {

               i=0;

           }

   return 0;

}

Explanation / Answer

//Hope This wil work

#include <msp430g2553.h>

/*

* main.c

*/

int main(void) {

WDTCTL = WDTPW | WDTHOLD;   // Stop watchdog timer

   int i;

  

   i=0;

       for ( i = 0; i < 61000; i+=10000 );

           if (i > 61000)

           {

               p1OUT=i;

i=0;

   return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote