So, basically i want to generate 50khz pwm signal on arduino nano digital pin9 and pin10. The waveform should look like the photo i have attached. I am using timer 1 for this purpose. By using the timer 1 in phase and frequency corrected pwm mode without prescaler and setting the top value OCR1A as 160 i can get 50khz signal.But in doing so, can i still use pin OC1A(pin9) as output to get pwm signals? Or do i loose it ?
It's not possible.
There are two mode:
8 1 0 0 0 PWM, Phase and Frequency Correct ICR1 BOTTOM BOTTOM
9 1 0 0 1 PWM, Phase and Frequency Correct OCR1A BOTTOM BOTTOM
Change to mode 8, setting ICR1 as frequency top value, and OCR1A as pin driver.
Okay thanks. I know about output compare registers. But what is ICR? How do they work?
Section 16.6 of the ATMega328P datasheet. Also Section 16.9.5.
The Nano cannot achieve kHz PWM with high resolution duty, but the ESP32 can and you can use the same source more or less.