frequense modification of PWM signal

Hi

I have a project where i whant to make a PWM signal between 2 kHz and 10 kHz, but the standart is 490-500hz. how do i modify the frequense?

Ideally there should be a library for more advanced driving of the timer/counter/pwm hardware - but it seems not.

You can look at the description in the ATmega datasheet. Its fairly complex as there are 16 different modes and three different timers.

I've an attempt at a tutorial for this stuff at http://www.mythic-beasts.com/~markt/ATmega-timers.html but it may not be very readable, its a first stab at it and incomplete.

This might help:

//Gestione PWMmode con frequenza base di 25K0Hz.

void setup(void){ //impostazione TIMER3 per PWMmode TCCR3A=0b00110010; TCCR3B=0b00010001; ICR3=32; OCR3B=16; }

what does the code do? sets the PWM frequnse to 25 kHz?? in that case how would I change it to lets say 2 kHz??

//Gestione PWMmode con frequenza base di 25K0Hz.

void setup(void){
 //impostazione TIMER3 per PWMmode
 TCCR3A=0b00110010;
 TCCR3B=0b00010001;
 ICR3=32;
 OCR3B=16;
}

I would like to know so I have an idea of what every part of my program does..

It sets the values in the counters. See the processor data sheet for a full explanation of what they do.