16Bit 125KHz PWM with PIC12F1572


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Aug 2011
    Posts
    460


    Did you find this post helpful? Yes | No

    Default Re: 16Bit 125KHz PWM with PIC12F1572

    I did try and test your suggestions for the 16F628 which worked except for the symetrical issue.
    That's probably because you're setting the CCP1CON CCP1X and CCP1Y bits, which control the duty cycle lsb's.
    Clear those two bits (ie CCP1CON = $0C for PWM mode).

    You should be able to get 125KHz with a 50/50 duty cycle at either 16MHz or 20MHz. You don't need 16-bit PWM for that.

  2. #2
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: 16Bit 125KHz PWM with PIC12F1572

    The 16-bit PWM Module in the PIC12F1572 takes cues from the 16-bit Output Compare (OC) Module. There are several FRMs that cover the dsPIC33 OC functions if you want a more elaborate explanation. If your PWM Clock is 4 MHz (Fosc/4 @ 16 MHz), each tick takes 0.000 000 250 seconds; or 0.25 uS. For 125 kHz, you need your Period to last for 32 Clock cycles. Unfortunately, that will be your resolution -- 0 >> 31. You cannot get 16-bit resolution -- or anywhere near that. Even setting Fosc to 32 MHz, yielding an 8 MHz Fosc/4, max resolution is still only 0 >> 63. The fastest PWM frequency with 16-bit resolution will be around 122 Hz (not kHz, just Hz). I had considered using this PIC for a previous project and decided to use a dsPIC33 instead, as I couldn't get a fast enough frequency out of the PIC12F1572.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: 16Bit 125KHz PWM with PIC12F1572

    If the dutycycle is supposed to be fixed at 50% I don't see how it matters if you have 5, 6, 7 or even 16 bits of resolution.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,172


    Did you find this post helpful? Yes | No

    Default Re: 16Bit 125KHz PWM with PIC12F1572

    A major limitation is that the chip does not support use of XTAL as a clock source. User needs to select either internal oscillator or external clock source, something that Jay is not fond of.

    I think crystal based clock is a must since the internal clock is specified at 2% and at 125Khz this means +/- 2.5KHz deviation.

    Ioannis

  5. #5
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: 16Bit 125KHz PWM with PIC12F1572

    Just another thought, the PSMC Peripheral found on some PIC16F17XX parts (and probably others) should at least clock from XTAL. It's a 16-bit PWM type control strategy.

Similar Threads

  1. 125KHz HW PWM Output
    By Zebryk in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 28th June 2022, 02:56
  2. Replies: 4
    Last Post: - 13th April 2022, 09:33
  3. PBP for dsPIC 16bit??
    By photoelectric in forum PBP Wish List
    Replies: 33
    Last Post: - 9th July 2014, 09:13
  4. Replies: 1
    Last Post: - 4th March 2013, 22:57
  5. Replies: 3
    Last Post: - 12th March 2008, 06:33

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts