Pages: [1]   Go Down
Author Topic: Outputting PWM frequency 200kHz  (Read 537 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is it possible to generate a PWM signal of 200kHz using the Arduino Nano? I have found examples of generating around ~65kHz by changing the settings of Timer0 using the line:

TCCR0B = TCCR0B & 0b11111000 | 0x01; 

It seems this is the maximum value that the timer can be set to. Is this just an unavoidable limit of the hardware?
« Last Edit: April 03, 2013, 01:08:12 pm by craighay1 » Logged

United Kingdom
Offline Offline
Tesla Member
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, although as timer 0 is also used to generate the time reported by the millis() function, using timer 0 for this will prevent millis() working. You might wish to use timer 2 instead. Configure the timer in fast PWM mode, set the prescaler to 1 and set TOP to (16MHz/200kHz - 1) = 79. You will have 80 steps of PWM (0 to 79) instead of the usual 256.

Formal verification of safety-critical software, software development, and electronic design and prototyping. See Please do not ask for unpaid help via PM, use the forum.

Pages: [1]   Go Up
Jump to: