Page 1 of 1
Clock source and PWM problem PIC12F1572
Posted: Wed May 03, 2017 8:11 am
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
Re: Clock source and PWM problem PIC12F1572
Posted: Wed May 03, 2017 10:22 am
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 (34.9 KiB) Viewed 5661 times
Re: Clock source and PWM problem PIC12F1572
Posted: Wed May 03, 2017 2:43 pm
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.
2. I tried all three options to set the PWM Timer, but the PWM output did not move.
Lagoda
Re: Clock source and PWM problem PIC12F1572
Posted: Mon May 08, 2017 11:18 am
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