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

A. Consider Example This example asked you to run C code on MPLAB to send values

ID: 1846043 • Letter: A

Question

A.    Consider Example

This example asked you to run C code on MPLAB to send values 00-FF to PORT B.

1.      #include <P18F458.h>                          

2.      void main(void)

3.        {

4.          unsigned char z;

5.          TRISB = 0;                           

6.          for(z=0;z<=255;z++)

7.            PORTB = z;

8.          while(1);                               

9.        }        

(d)   Show how you do this if you want to replace the original for loop (of lines 6 and 7) by a while loop (you still have while(1) in line 8). Yes, this is an ECE 114 question.

While(z<255)

   PORTB=z

    z++

while(1)

(e) Show how you can do this if you want PORTB = z; for even z and PORTC = z; for odd z. The range of z is from 0 till 255 as original code

Explanation / Answer

(d)   


the for loop of lines 6 and 7 can be replaced by :


z=0;

while(z<=255)

{

PORTB = z;

z++;

}






(E)


z=0;

while(z<=254)

{

PORTB = z;

z = z+2;

}


z = 1;

while(z<=255)

{

PORTC = z;

z = z+2;

}


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