Adjusting PWM frequency with Timer 2

I read this forum But I want PWM frequency ranging from 2kHz-3KHz.I am varying the duty cycle using the function analogwrite function and I need to use this.I just want my frequency fixed to be under 5kHz.Any help out there. thanks

So, use divisor setting 0x02 to get 3.90625 KHz. That is less than 5 KHz. What is the problem?

Yes. 4 KHz is there.I need to test with even lower frequency especialy 2-3kHz.Infact I want something that I can easily vary from 1-3KHZ.The given set has either 1 or 4kHz only.

I want something that I can easily vary from 1-3KHZ

On one or two outputs?

With what resolution?

"Easily" in what sense? Changed at run-time by your Sketch? Changed at compile-time by you?

If you reduce the PWM range by setting a lower TOP value (OCR2A) you can get a faster PWM rate. Since you want LOWER rates you'd have to switch to a slower prescaled clock rate (/32) which will give you a clock rate of 976.5625 Hz. Then, by setting TOP to values between 250 and 83 you should be able to get rates in the 1 KHz to 3 KHz range. At 3 KHz you will only have 83 steps of PWM between full off and full on.

Of course I have not tried this and have no idea if the timer can be used in this way.

At Coding Badly,
One Output only,its a 8 bit PWM, arduino PRO-Mini ATMEGA328 5V.Its changed at compile.
Like here: TCCR2B = TCCR2B & 0b11111000 | ;
where you can just change the setting by some hex number and easily gives you some descrete PWM.I want like 2,3 KHz.

@johnwasser has pointed you in the correct direction. You will change the timer to a different mode and then follow his advice for setting the frequency.

Before proceeding, you need to answer the final question ... With what resolution? With a TOP value of 83 (3 KHz frequency) you will have a resolution of 1.19% (1/(83+1)*100); you will be able to adjust the output in 1.19% increments. Another way to look at it is you will have 84 steps between full off and full on. Is that enough for your application?