1. Engineering
  2. Electronics Engineering
  3. consider a pic32 microcontroller with a builtin pwm peripheral using...

Question: consider a pic32 microcontroller with a builtin pwm peripheral using...

Question details

Consider a PIC32 microcontroller with a built-in PWM peripheral using Timer 2.

• The processor clock frequency is 80 MHz.

• The Timer 2 clock frequency can be set to the processor clock frequency, optionally divided by 1, 2, 4, 8, 16, 32, 64 or 256.

• Every cycle of the Timer 2 clock, the contents of the TMR2 memory location is increased by 1.

• The PR2 memory location sets the PWM frequency.

• TMR2 counts from 0 to PR2 inclusive and then begins again from 0.

• A new PWM period begins whenever TMR is reset to 0.

• The OC2R memory location sets the PWM duty cycle.

• If TMR2 < OC2R the PWM output pin is high; if TMR2 ≥ OC2R the PWM output pin in low.

a) If the Timer 2 clock frequency is set to 80 MHz/256 = 312.5 kHz, what value of PR2 should be used for a PWM frequency of 50 Hz? ( 5 marks)

b) Using the value if PR2 calculated above, what value of OC2R should be used for a PWM duty cycle of approximately 45%? ( 5 marks)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution