Go Down

Topic: Outputting > 5 MHz PWM signal (Read 674 times) previous topic - next topic


Jul 15, 2013, 10:40 pm Last Edit: Jul 18, 2013, 12:56 am by elevine Reason: 1
I'm attempting to configure the bit registers for Timer 2 so that pins 3 (and 11) produce a PWM signal that is >5 MHz. I already have a good understanding of what I have to do from reading these two websites:


-Change prescale factor to lowest setting possible (1)
-Change the timer top limit OCR2A (to maybe around 9)
-Toggle OCR2A on Compare Match
-Set ORC2B (around 4)

This would theoretically give an output frequency of: 84 MHz/ 1 / (9+1) = 8.4 MHz with a duty cycle of: (4+1) / (9+1) = 50%

I have even begun to figure out the syntax for setting these bits and most of it makes sense.

The main issue: What is the code that actually goes into my void setup() function to make this happen?

When I tried copying some of the code from the first website listed, I get a compile error saying "'TCCR2A' was not declared in this scope. I'm not void of all programming knowledge, so I know there must be some library or include# command that I need at the beginning of my code to properly reference these bit registers but I haven't found any information after searching online for some hours.

Any help would be much appreciated.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131