Go Down

Topic: Outputting PWM frequency 200kHz (Read 671 times) previous topic - next topic

Apr 03, 2013, 06:28 pm Last Edit: Apr 03, 2013, 08:08 pm by craighay1 Reason: 1
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?


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 http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

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