[SOLVED] PWM near 2K Hz?


i'm trying build pwm driver out of arduino. target around 2khz. reading following reference:

http://playground.arduino.cc/code/pwmfrequency


from numbers given, seems can't near 2khz. 1khz , 4khz (3.9khz) doable pins 2khz not. correct conclusion?

you can absolutely 2khz.

just take on 1 of timers, yourself, don't try work guy's code. have serious concerns (a lot of code in arduino playground of dubious quality, sad say)

anyway, take on timer1, ideally - it's 16-bit have more options.

put wgm top value controlled icrn register, , adjust ocrnx registers match intended duty cycle.

want 2 khz? okay, 16mhz / 2khz = 8000, want 8000 clock cycles. if set prescaler 1, , icr1 8000, timer1 count 1 8000, , 2000 times per second. if want squarewave, set ocrnx register channel want 4000.

the appropriate section of datasheet lays out (if don't think said above makes sense, read section on timer1 in datasheet - should explain things)


Arduino Forum > Using Arduino > Project Guidance > [SOLVED] PWM near 2K Hz?


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'