Page 1 of 1
I want a PWM frequency of 4.1KHz.
Posted: Mon Dec 28, 2020 5:33 pm
by rradojko
Hello,
I want a PWM frequency of 4.1KHz. I am using Flowcode9 and Arduino Nano (Atmega328)
But, whatever I type in the Overflow Period, the PWM frequency does not change (see picture).
Where is the problem?
Re: I want a PWM frequency of 4.1KHz.
Posted: Mon Dec 28, 2020 11:47 pm
by BenR
Hello,
When compiling to chip you likely are getting a warning that your target device doesn't have a period register, hence the value cannot be changed on your device from the default value of 256. I'll see if I can make this more obvious in the component as I'm sure it's very frustrating.
Re: I want a PWM frequency of 4.1KHz.
Posted: Tue Dec 29, 2020 8:46 pm
by rradojko
Hello,
Thanks Ben for the answer.
I tried compiling again.
Really issue a warning "Period control register not available on target device, period will default to 255 + 1"
It would be good if the warning was written in red.
I would ask you if you can find a solution to this. The Atmega328 is a very popular processor.
Now I can only select 5 different PWM frequencies. This choice is too small. This is very disturbing.
Thank you and have a nice day.
Re: I want a PWM frequency of 4.1KHz.
Posted: Tue Dec 29, 2020 8:55 pm
by BenR
Hello I'm afraid it's a limitation of the atmega328 hardware and not the software. You could maybe create software based pwm using a timer interrupt to give you more control over the output frequency.
Re: I want a PWM frequency of 4.1KHz.
Posted: Wed Dec 30, 2020 10:27 pm
by rradojko
All right, I understand.
I also tried PWM chanel 3. PWM chanel 3 uses timer1.
Timer1 has multiple registers to set up and is 16bit.
Unfortunately, timer1 does not work either.
Although the datasheet says "Timer1 Variable PWM period".
Why doesn't PWM work? There is no pwm signal on PORT B3.
Thank you and have a nice day.
Re: I want a PWM frequency of 4.1KHz.
Posted: Thu Dec 31, 2020 11:53 am
by rradojko
I tried again.
If I select PWM Chanel3 there is no more warning "Period control register not available on target device, period will default to 255 + 1"
There is no PWM signal on port B1.
What is wrong?
I am also attaching a test program.
Re: I want a PWM frequency of 4.1KHz.
Posted: Tue Sep 06, 2022 8:35 pm
by zoli2496
PWM doesn't work at all for me either. Arduino Nano. Chanel1-6, nothing. Please help me.

- pwm.gif (52.48 KiB) Viewed 4518 times

- pwm2.gif (125.32 KiB) Viewed 4517 times
Re: I want a PWM frequency of 4.1KHz.
Posted: Wed Sep 07, 2022 8:45 am
by medelec35
Hello.
Unfortunately, a screenshot does not help.
For any issues, can you please attach your fcfx project.
For example, if the ADC component was set to AREF and you have not connected a jumper from AREF to 5V, then PWM will not work as expected.
Without a jumper, you will need to set AREF to AVCC.
I have done that in the attached project, which works on hardware.
If you want a wider frequency range, then you will need a timer-based interrupt PWM as Ben has suggested in an above post.
Re: I want a PWM frequency of 4.1KHz.
Posted: Sun Sep 11, 2022 5:40 am
by zoli2496
Hello.
After I switched the potentiometer to AVCC, it worked right away.

Thank you very much!