Pic 16bit PWM

A forums to allow resolved bugs and problems with Flowcode v7 to be stored and marked as resolved.

Moderator: Benj

dz28
Posts: 18
Joined: Thu Aug 04, 2016 3:30 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Pic 16bit PWM

Postby dz28 » Sat Aug 06, 2016 12:16 am

I have a project using the PIC12F1572
I am using the PWM component.
The component appears to be setup as an 8bit PWM using TMR2 as the clock source driven by Fosc/4

The PIC12F1572 has a 16bit PWM with associated 16bit timer module using Timer2 is not an option.
The period register is 16bit not 8bit

Am I missing something or is this component setup wrong?

Thanks,
DC

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

Re: Pic 16bit PWM

Postby Benj » Sat Aug 06, 2016 7:57 pm

Hi DC,

I'll investigate for you and check there is not a bug in the device definition file.

dz28
Posts: 18
Joined: Thu Aug 04, 2016 3:30 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Pic 16bit PWM

Postby dz28 » Sun Aug 07, 2016 2:20 am

ok
thanks

DC

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

Re: Pic 16bit PWM

Postby Benj » Mon Aug 08, 2016 2:57 pm

Right I think I have a fix for you now.

I've added a new PWM handler in the PIC CAL, updated the chip definition files and updated the PWM component.

First the definition file needs to go in the "Flowcode 7/FCD/PIC" folder.

12F1572.fcdx
(16.15 KiB) Downloaded 112 times


Next the components need to go in the "Flowcode 7/components" folder.

PWM.fcpx
(7.86 KiB) Downloaded 119 times

cal_pwm.fcpx
(8.04 KiB) Downloaded 114 times


Finally the CAL C file needs to go in the "Flowcode 7/CAL/PIC" folder.

PIC_CAL_PWM.c
(28.49 KiB) Downloaded 129 times


Start or Restart Flowcode and you should be able to select the appropriate clock source and set the period property with a value up to 65535.

You will need to use the SetDuty10Bit macro to access the full PWM duty cycle range. SetDuty will set the upper 8-bits of the PWM duty register.

Please note that the simulation may not work out the time duration and frequencies correctly at the moment, especially for the alt clock sources LFINTOSC and HFINTOSC.

Let me know how you get on.

dz28
Posts: 18
Joined: Thu Aug 04, 2016 3:30 pm
Has thanked: 1 time
Been thanked: 2 times
Contact:

Re: Pic 16bit PWM

Postby dz28 » Sun Aug 14, 2016 2:59 pm

Thanks for looking into this
Just got back from vacation.
I'll check it out this week and get back to you

Thanks
DC
These users thanked the author dz28 for the post:
Benj (Sun Aug 14, 2016 8:56 pm)
Rating: 5.88%