Clock source and PWM problem PIC12F1572

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

Moderator: Benj

Post Reply
Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

Clock source and PWM problem PIC12F1572

Post by Lagoda »

Hello,

I would like to use the PWM module of the 12f1572 microcontroller, with internal clock source.

1. But I do not know how to select the proper internal clocks.
By default, the internal clock speed is 500KHz (FOSC = 125KHz) so I tried the PWM output with it.

2. Unfortunately, the PWM output does not work in the circuit board.

Thanks in advance for your help.

Lagoda
Attachments
PWM_12F1572.fcfx
(6.18 KiB) Downloaded 308 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: Clock source and PWM problem PIC12F1572

Post by Benj »

Hello Lagoda,

1. Have you seen the IntOsc helper component available from the Tools component category? It contains specific information about what speeds are available and what C code is required to configure the oscillator correctly. Use a one second flasher to confirm you are running at the speed you think you are.

2. Please can you try setting the PWM timer property to LFINTOSC or HSINTOSC, it looks like the FOSC is for the external oscillator, but I could be wrong on this.
Fosc.jpg
Fosc.jpg (34.9 KiB) Viewed 4803 times

Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

Re: Clock source and PWM problem PIC12F1572

Post by Lagoda »

Hi Ben,

1.Thanks for the advice. (I was searching this setup it in Project Options, Configuration). I have not used the "IntOsc Helper" component before. I succeeded in setting the clock with it. :D

2. I tried all three options to set the PWM Timer, but the PWM output did not move. :|

Lagoda
Attachments
PWM_12F1572_1.fcfx
(7.07 KiB) Downloaded 290 times

Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

Re: Clock source and PWM problem PIC12F1572

Post by Lagoda »

Hi Ben,

I've been experimenting with PWM this weekend.
The 8-bit PIC microcontroller's 16-bit PWM module is more complex than the traditional 8-bit PWM module. There are several modes and several parameters must be set to produce the correct output signal.
The PWM component of Flowcode writes into the "Period Register" and in the "Duty Cycle Register" only. The Offset Register and Phase Register are not initialized.
When the contents of the registers are rewritten, they are first writes into a buffer and then have to update with a LOAD statement.
The same PWM module is included in the Flowcode supported 12F1571, 16F1764, 16F1765, 16F1767, 16F1768, 16F1784, 16F1786, 16F1787, 16F1788, 16F1789, and 16F1789.
In the attached program, the 12F1572 microcontroller is operated in "Standard PWM Mode".
Unfortunately, during the simulation, the PWM parameters on the Dashboard Panel are incorrect.

Best Regards,

Lagoda
Attachments
PWM_12F1572_Standard_Mode.fcfx
(7.46 KiB) Downloaded 360 times
Standard_PWM_Mode.png
(43.28 KiB) Downloaded 2776 times

Post Reply