I 'm using the code below to control a pwm-fan which needs 25khz pwm frequency, it works well.
But now i want to add another fan on pin 7 (same timer used).
How can i do that and use different pwm-values for each pin?
I read about using analogWrite25k(pin, value) but i get errors when i try to use it.
void analogWrite25k(int value)
{
OCR4C = value;
}
void setup()
{
TCCR4A = 0;
TCCR4B = 0;
TCNT4 = 0;
TCCR4A = _BV(COM4C1) // non-inverted PWM on ch. C
| _BV(WGM41); // mode 10: phase correct PWM, TOP = ICR4
TCCR4B = _BV(WGM43)
| _BV(CS40); // prescaler = 1
ICR4 = 320; // TOP = 320
// Set the PWM pin as output.
pinMode( 8, OUTPUT);
}
void loop()
{
analogWrite25k(80);
for (;;) ; // infinite loop
}