Question & Answer: (a) The following C program includes at least 10 basic errors, either as:  syntax errors (code the compiler will not understand) or…..

(a) The following C program includes at least 10 basic errors, either as:

 syntax errors (code the compiler will not understand) or

 simple programming/logic errors. (code that will compile, but not work as expected)

The purpose of this program is to produce a Pulse Width Modulated output on a pin, where the ON time is proportional to the 8 bit value read from PORTB. The shortest pulse is produced for an input value 1 and longest pulse for an input value 255.

The program is to loop endlessly turning on (1) PORTC bit 1 at count 0, then turning off (0) PORTC bit 1 when count equals the value read in from PORTB. The counter is to count on to 255 defore the This is shown diagrammatically as an example below.

Output Start Read Input 100 Value 100 2550, 1 Count 0, 1 Output ONI Output OFF include <xc.h void main(void) intitialise 0: PORTB Val; while (0) for count 0 count 255; count++ if (count val PORTC 30x01 else PORTC 0x00; intitialise(void) TRISB 0x00; TRISC 0x00, 50 2550, 1 50 2550, 1

Copy the program (as written above) into your notebook and circle the location of

each error, write the corrected program beside the original on right-hand side of your
page.

Expert Answer

 

Still stressed from student homework?
Get quality assistance from academic writers!