Answered You can hire a professional tutor to get the answer.
48622 Mechatronics 1 - PIC18 C - Find the Bugs Initial Task:
48622 Mechatronics 1 - PIC18 C - Find the Bugs
• You are trying to determine the period (in µs) of a PWM Signal connected to pin RG3 by using the ECCP2 Module and outputting it using printf().
• Timer3 is currently being used as heartbeat signal generator by code in an invisible library.
• The code is not working ☹. Find what's wrong and fix it.
• Fosc = 48MHz
• Minimum PWM capture period = 100µs (10KHz
) • Maximum PWM capture period = 10,000µs (100Hz)
• printf() is instant and requires no setup. Also ALL required libraries are included automagically.
• This is not the MXK (i.e. all information needed is in the datasheet). • THERE ARE 7 BUGS IN THIS EXAMPLE Symptoms:
• It does nothing except print the lines: o Raw Register = 0 o PWM Period = 0 us o PWM Frequency = 0 KHz
Code is on the Next Page.
Extra Task: This code could be written better. It repeats itself in a few sections and could use some refactoring all around (cleaning it up). Try understanding what it is trying to do and refactor it using conditionals/functions/variable/return types/parameters/etc. To make it easier to read and understand and possibly shorter.