Arduino Nano 3.0 - Custom PWM Generating

Hi,
I need to generate two PWM signals at 100Hz.
I wrote something like this:

/**************************************************************************
    PWM
***************************************************************************/
#define PROVAL_RFR_RATE           100                                      // In Hz
#define PROVAL_TOP_VAL            (uint16_t)(1000000L / PROVAL_RFR_RATE)
int proval[2];

void setup() {
  InitPWM();
}

void loop() {

}


/**************************************************************************
   PROVAL (Proportional Valve)
***************************************************************************/
void InitPWM() {
  TCCR1A |= (1<<WGM11); // phase correct mode & prescaler to 8
  TCCR1A &= ~(1<<WGM10);
  TCCR1B &= ~(1<<WGM12) &  ~(1<<CS10) & ~(1<<CS12);
  TCCR1B |= (1<<WGM13) | (1<<CS11);
  ICR1 = PROVAL_TOP_VAL;
  pinMode(9, OUTPUT);   TCCR1A |= (1<<COM1A1); // pin 9  PROVAL 1
  pinMode(10, OUTPUT);  TCCR1A |= (1<<COM1B1); // pin 10 PROVAL 2
  provalWrite();
}

void provalWrite() {
  OCR1A = proval[0]; // pin 9
  OCR1B = proval[1]; // pin 10
}

I have just a few questions:

  • Is my basic code correct?
  • In this mode what is the minimum value to obtain 0% PWM and maximum value to obtain 100% PWM output?

Thank to all.

please I need some help...

I have just a few questions: Is my basic code correct?

Close. Your code produces a 100Hz square wave when you write values into int proval[2]. Nowhere in the code do you actually write a non zero value into proval[].

In this mode what is the minimum value to obtain 0% PWM and maximum value to obtain 100% PWM output?

The way you have the output pins set up is to clear on incrementing(counting up) and set on decrementing(counting down). My understanding is that proval = 0 will be 0% pwm and proval = 10,000 will be 100%.