Hi,
i'm using a pic18f4550, speed up at 16Mhz and an Easypic6 board with mikroC. I want use the
PWM module initialized at 50Hz, but the compiler write "Argument is out of range Pwm_1.c".
The minimum frequency that i can use is 1KHz. Is possible use a 50Hz frequency?
There is any setting to set up or is impossible a similar frequency?
Best regards,
Ivan
PWM problem
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: PWM problem
Hello,
PWM module use timer module for counting and generating frequency.
So this limits minimal frequency that can be generated.
From this point of view I can confirm that you can not generate 50Hz with 16MHz MCU clock.
You can use slower clock on MCU, or software PWM (which is better solution).
Best regards.
PWM module use timer module for counting and generating frequency.
So this limits minimal frequency that can be generated.
From this point of view I can confirm that you can not generate 50Hz with 16MHz MCU clock.
You can use slower clock on MCU, or software PWM (which is better solution).
Best regards.
Re: PWM problem
Hi,
thanks for the answer,but there is any formula to calculate the right clock
on MCU to generate a specific frequency?
Best regards,
Ivan
thanks for the answer,but there is any formula to calculate the right clock
on MCU to generate a specific frequency?
Best regards,
Ivan
- janko.kaljevic
- Posts: 3565
- Joined: 16 Jun 2011 13:48
Re: PWM problem
Hello,
Yes there is.
Please notice details in following document on page 155.
http://ww1.microchip.com/downloads/en/D ... 39632e.pdf
This formula is calculated in library, and you should use just to see which combination of MCU and PWM frequency you can use for your project.
But still I think that software PWM is better solution.
Best regards.
Yes there is.
Please notice details in following document on page 155.
http://ww1.microchip.com/downloads/en/D ... 39632e.pdf
This formula is calculated in library, and you should use just to see which combination of MCU and PWM frequency you can use for your project.
But still I think that software PWM is better solution.
Best regards.
- Attachments
-
- P18F4550-PWM.JPG (41.77 KiB) Viewed 1663 times