sorry,it‘s my mistake ....
I corrected the mistake in my code,
give this code to show how to use timer to control pwm.
HardwareTimer timer1(2);
void setup(){
pinMode(1,PWM);
timer1.pause();
timer1.setPrescaleFactor(9);
timer1.setOverflow(1);
//timer1.setMode(1,TIMER_PWM);
timer1.setCompare(2,1);
timer1.refresh();
timer1.resume();
}
void loop(){}