Can we still lower clock speed for PWM?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
mimiyum
Posts: 94
Joined: Wed Jul 16, 2008 4:39 pm
Location: Philippines
Been thanked: 1 time
Contact:

Can we still lower clock speed for PWM?

Post by mimiyum »

Hello,

I am trying to program a 16F877a using the EB-006 Board with
clock speed set =1,000,000 Hz
PWM is set at
Period=255
Clock Source= clk/16

Crystal we are using is 19mhz.

This is supposed to have a frequency of 61.03516 Hz.

When we test the 16f877a with a scope, we read 1kHz. Its as if the clock source is not clk/16.

I noticed that minimum clock speed is already 1,000,000 Hz. Is there a way to set it lower?

Or is there another way of achieving this?

Basically our goal is to get a frequency of around 60hz.

Thanks.

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

Re: Can we still lower clock speed for PWM?

Post by medelec35 »

If crystal is 19MHz, then you must set your clock speed to 19000000 to match, or if a 19660800 crystal, set clock speed to that.
If you have a crystal lower than 1MHz, or a different crystal to the Flowcode selection, then you can manually type in correct clock speed.
If crystal speed does not match Flowcode clock speed, then all timings will out, and you will not measure expected waveforms or delays.
The PWM clock speed is set by right clicking on PWM and selecting Ext properties.
Note the Clock speed you see in the properties is the same as speed of the crystal you are using so at 19.6 MHz as far as I am aware this value can't be altered. 1.2 KHz is the slowest frequency the pwm will work out.
Unless anyone else has suggestions, what about using timer 0 for bit bang PWM?
There are example files on this in the forum.
If you want PWM module set at 61Hz then you must have a 1MHz Crystal connected to your chip not 19MHz.
Martin

mimiyum
Posts: 94
Joined: Wed Jul 16, 2008 4:39 pm
Location: Philippines
Been thanked: 1 time
Contact:

Re: Can we still lower clock speed for PWM?

Post by mimiyum »

Thanks so much for pointing that out. It's fine now. I know i need a 1mhz crystal to get 61hz. Unfortunately, we can't find a 1mhz in the market at the moment :cry:

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

Re: Can we still lower clock speed for PWM?

Post by medelec35 »

Have you thought about using an interrupt timer for producing PWM at 60Hz?That would be easily achievable.
Martin

mimiyum
Posts: 94
Joined: Wed Jul 16, 2008 4:39 pm
Location: Philippines
Been thanked: 1 time
Contact:

Re: Can we still lower clock speed for PWM?

Post by mimiyum »

Thanks Medelec I think I can work with 122hz and I don't want to confuse my loops with the interrupt timer :shock:

That idea should come in handy for another application, though :P

Post Reply