PWM problem

General discussion on mikroC.
Post Reply
Author
Message
ivans
Posts: 104
Joined: 12 Apr 2011 16:48
Location: Italy

PWM problem

#1 Post by ivans » 17 Mar 2012 15:37

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

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: PWM problem

#2 Post by janko.kaljevic » 19 Mar 2012 10:28

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.

ivans
Posts: 104
Joined: 12 Apr 2011 16:48
Location: Italy

Re: PWM problem

#3 Post by ivans » 19 Mar 2012 21:40

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

User avatar
janko.kaljevic
Posts: 3565
Joined: 16 Jun 2011 13:48

Re: PWM problem

#4 Post by janko.kaljevic » 20 Mar 2012 10:53

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.
Attachments
P18F4550-PWM.JPG
P18F4550-PWM.JPG (41.77 KiB) Viewed 1663 times

Post Reply

Return to “mikroC General”