Question: Timers and PWM. For this problem assume a CPU frequency of 19MHz. a). Give the C code to configure the registers (e.g. TCCR0A, etc.) to

Timers and PWM. For this problem assume a CPU frequency of 19MHz.

a). Give the C code to configure the registers (e.g. TCCR0A, etc.) to set the 8-bit Timer0 in Fast PWM mode with a frequency as close to 500Hz as possible. Comment each line of code to indicate how you are configuring it. Remember to assume a 18MHz clock frequency. Hint: You should try all of the possible clock prescalers to determine which gives you the best value.

b) What is the actual frequency that the timer will run at?

c) How would you configure it to approximately a 30% duty cycle (on 30% of the time)? Give the C code setting the Atmel registers to do this (make sure to set OCR0B).

d) If you used Timer1 instead, could you get closer to an actual frequency of 500Hz? Configure the registers for Timer1 for 500Hz and make sure to show and comment your code. What is the actual frequency you achieve with your configuration?

e) Describe the differences between Fast PWM and Phase Correct PWM mode and why you may want to use Phase Correct PWM in some circumstances. You may want to include a picture of the signals to help with your description.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!