Page 1 of 1

Pic 16bit PWM

Posted: Sat Aug 06, 2016 12:16 am
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

Re: Pic 16bit PWM

Posted: Sat Aug 06, 2016 7:57 pm
by Benj
Hi DC,

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

Re: Pic 16bit PWM

Posted: Sun Aug 07, 2016 2:20 am
by dz28
ok
thanks

DC

Re: Pic 16bit PWM

Posted: Mon Aug 08, 2016 2:57 pm
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 319 times
Next the components need to go in the "Flowcode 7/components" folder.
PWM.fcpx
(7.86 KiB) Downloaded 357 times
cal_pwm.fcpx
(8.04 KiB) Downloaded 346 times
Finally the CAL C file needs to go in the "Flowcode 7/CAL/PIC" folder.
PIC_CAL_PWM.c
(27.36 KiB) Downloaded 358 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.

Re: Pic 16bit PWM

Posted: Sun Aug 14, 2016 2:59 pm
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