Pages: [1]   Go Down
Author Topic: Outputting > 5 MHz PWM signal  (Read 441 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM
http://web.alfredstate.edu/weimandn/miscellaneous/atmega168_subsystem/ATmega168%20Timer-Counter2%20Compare%20Match%20A%20v02.pdf

-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.


« Last Edit: July 17, 2013, 05:56:59 pm by elevine » Logged

Pages: [1]   Go Up
Jump to: