BUG PWM

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

Post Reply
User avatar
Osta
Posts: 159
Joined: Tue Jul 05, 2016 9:42 am
Been thanked: 13 times
Contact:

BUG PWM

Post by Osta »

Incorrectly generates the PWM frequency!
If you initialize the initialization, then everything is correct!
Attachments
Reciever.fcfx
Here is the project
(5.56 KiB) Downloaded 224 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BUG PWM

Post 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
Martin

User avatar
Osta
Posts: 159
Joined: Tue Jul 05, 2016 9:42 am
Been thanked: 13 times
Contact:

Re: BUG PWM

Post 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
Attachments
Reciever.fcfx
(5.56 KiB) Downloaded 228 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: BUG PWM

Post 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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BUG PWM

Post 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

Code: Select all

8000000
to

Code: Select all

 32000000
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.
Martin

User avatar
Osta
Posts: 159
Joined: Tue Jul 05, 2016 9:42 am
Been thanked: 13 times
Contact:

Re: BUG PWM

Post by Osta »

Thank you !!
I'm going to try now.

User avatar
Osta
Posts: 159
Joined: Tue Jul 05, 2016 9:42 am
Been thanked: 13 times
Contact:

Re: BUG PWM

Post by Osta »

It works the same way ...
From the permutation of the macro, the PWM frequency changes
Attachments
Reciever.fcfx
(5.57 KiB) Downloaded 221 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: BUG PWM

Post by medelec35 »

I have just tried using internal osc:
PWM setup frequency.png
(42.59 KiB) Downloaded 4146 times
loaded 16F1824 with compiled hex.
PWM from pin C5:
PWM Waveform.png
(102.68 KiB) Downloaded 4146 times
As hardware agrees with PWM settings within Flowcode, I can't tell what the issue is?

If you can measure frequency, can you set

Code: Select all

Clock out enable
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
Martin

User avatar
Osta
Posts: 159
Joined: Tue Jul 05, 2016 9:42 am
Been thanked: 13 times
Contact:

Re: BUG PWM

Post by Osta »

Hi, Martin !
I'm not talking about setting up.
And about the compilation ....
Here is my example.
Attachments
_Down.jpg
Initialization at the bottom
(932.67 KiB) Downloaded 38 times
_UP.jpg
Initialization at the top
(937.37 KiB) Downloaded 38 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: BUG PWM

Post 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.

User avatar
Osta
Posts: 159
Joined: Tue Jul 05, 2016 9:42 am
Been thanked: 13 times
Contact:

Re: BUG PWM

Post by Osta »

Hello Benj!
I thought that the linker has priorities,
Thank you for the clarification.
Thank you Osta.

Post Reply