Clock source and PWM problem PIC12F1572

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

Moderator: Benj

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Clock source and PWM problem PIC12F1572

Postby Lagoda » Wed May 03, 2017 8:11 am

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 119 times

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

Re: Clock source and PWM problem PIC12F1572

Postby Benj » Wed May 03, 2017 10:22 am

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 2699 times
These users thanked the author Benj for the post:
Lagoda (Wed May 03, 2017 2:47 pm)
Rating: 5%
 

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: Clock source and PWM problem PIC12F1572

Postby Lagoda » Wed May 03, 2017 2:43 pm

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 120 times
These users thanked the author Lagoda for the post:
Benj (Wed May 03, 2017 3:50 pm)
Rating: 5%
 

Lagoda
Posts: 152
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: Clock source and PWM problem PIC12F1572

Postby Lagoda » Mon May 08, 2017 11:18 am

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 135 times
Standard_PWM_Mode.png
Standard_PWM_Mode.png (43.28 KiB) Viewed 2665 times
These users thanked the author Lagoda for the post:
Benj (Tue May 09, 2017 11:44 am)
Rating: 5%