Pic 16bit PWM

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

Moderator: Benj

Post Reply
dz28
Posts: 60
Joined: Thu Aug 04, 2016 3:30 pm
Has thanked: 7 times
Been thanked: 9 times

Pic 16bit PWM

Post by dz28 »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Pic 16bit PWM

Post by Benj »

Hi DC,

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

dz28
Posts: 60
Joined: Thu Aug 04, 2016 3:30 pm
Has thanked: 7 times
Been thanked: 9 times

Re: Pic 16bit PWM

Post by dz28 »

ok
thanks

DC

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: Pic 16bit PWM

Post by Benj »

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 401 times
Next the components need to go in the "Flowcode 7/components" folder.
PWM.fcpx
(7.86 KiB) Downloaded 411 times
cal_pwm.fcpx
(8.04 KiB) Downloaded 423 times
Finally the CAL C file needs to go in the "Flowcode 7/CAL/PIC" folder.
PIC_CAL_PWM.c
(27.36 KiB) Downloaded 414 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: 60
Joined: Thu Aug 04, 2016 3:30 pm
Has thanked: 7 times
Been thanked: 9 times

Re: Pic 16bit PWM

Post by dz28 »

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

Thanks
DC

Post Reply