fixed bugs around PWM digital and analog mode; tuned PWM frequency for analog mode