Page 1 of 1
BUG PWM
Posted: Sun Mar 12, 2017 3:22 pm
by Osta
Incorrectly generates the PWM frequency!
If you initialize the initialization, then everything is correct!
Re: BUG PWM
Posted: Mon Mar 13, 2017 11:00 am
by medelec35
Hi Osta,
I have not got 8MHz crystal so using internal oscillator.
PWM frequency looks correct to me.
One thing I had to do first was disable PLL as you have got clock speed set to 8MHz, yet PLL enabled will make chip run at 8x4 = 32MHz.
So there is a mismatch.
What PWM frequency are you measuring and expecting?
What clock speed are you expecting hardware to run at (8 or 32MHz)?
Martin
Re: BUG PWM
Posted: Tue Mar 14, 2017 12:41 pm
by Osta
Hi, Martin!
All right!
It's not about PLL ...
I need PLL.
If the PWM initialization macro is put after the PWM settings, then everything will change and the PWM frequency will be incorrect!
The same project but with the initialization
Re: BUG PWM
Posted: Tue Mar 14, 2017 1:05 pm
by Benj
Hello,
If you're using the PLL then you need to change your clock speed setting to 32000000 in the project options. The properties for the PWM component should then show you what frequencies to expect.
Re: BUG PWM
Posted: Tue Mar 14, 2017 1:06 pm
by medelec35
Hi Osta,
Osta wrote:I need PLL.
In that case you must first go to Build, Project Options then General options tab.
Change Clock speed from
to
You are also best having Enable as first component to be accessed.
You also don't require change period if you just have a single fixed PWM frequency.
Just set correct frequency within PWM properties as at least you will know what the frequency should be.
Much better than change period.
Martin
Edit: posts crossed so information could be repeated.
Re: BUG PWM
Posted: Tue Mar 14, 2017 1:45 pm
by Osta
Thank you !!
I'm going to try now.
Re: BUG PWM
Posted: Tue Mar 14, 2017 1:51 pm
by Osta
It works the same way ...
From the permutation of the macro, the PWM frequency changes
Re: BUG PWM
Posted: Tue Mar 14, 2017 5:05 pm
by medelec35
I have just tried using internal osc:
loaded 16F1824 with compiled hex.
PWM from pin C5:
As hardware agrees with PWM settings within Flowcode, I can't tell what the issue is?
If you can measure frequency, can you set
to enabled, within configuration settings.
Then measure frequency on pin A3.
You should measure 32/4 8MHz even though clock is running at 32 MHz.
Martin
Re: BUG PWM
Posted: Wed Mar 15, 2017 10:23 am
by Osta
Hi, Martin !
I'm not talking about setting up.
And about the compilation ....
Here is my example.
Re: BUG PWM
Posted: Wed Mar 15, 2017 10:47 am
by Benj
Hello,
The PWM Enable component macro calls the Change Period for you using the values in the component properties.
If you want to use values other than those specified in the properties then you need to call the Change Period macro again after enabling the PWM.
Re: BUG PWM
Posted: Wed Mar 15, 2017 11:02 am
by Osta
Hello Benj!
I thought that the linker has priorities,
Thank you for the clarification.
Thank you Osta.