16Bit 125KHz PWM with PIC12F1572


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: 16Bit 125KHz PWM with PIC12F1572

    FYI:

    1. I just requested a current PBP manual to see if the HWPWM feature now includes >32767Hz.
    2. I have the PIC12F1572 data sheet which seems to have a completely differenct PWM operation than the 16F628.
    3. I did try and test your suggestions for the 16F628 which worked except for the symetrical issue.

    Below is the App so far with Zero progress on the PWM.
    All it will do is modulate an 125KHz magnetic antenna using OOK.

    Currently, I have configured the internal OSC for 16MHz.
    I do not know whether the 4X PLL is required for a perfectly symetrical On/Off Duty Cycle of 4uS On / 4uS Off.

    Peace,

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,696


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: 16Bit 125KHz PWM with PIC12F1572

    3. I did try and test your suggestions for the 16F628 which worked except for the symetrical issue.
    what did you try , post your code

    Currently, I have configured the internal OSC for 16MHz.
    all those calc's are for a 20MHz clock if you use a different OSC then they must be recalculated

    the internal OSC is not brilliantly accurate and could need trimming to approximate a symmetrical output


    on paper these settings are incorrect for 16 or 20 MHz
    ' OLD SETTINGS FROM 16F628




    'PR2 = %00001001 ' dec 9 47.5%
    'T2CON = %00000101 ' dec 5
    'CCPR1L = %00000100 ' dec 4
    'CCP1CON = %00111100 ' dec 60
    Warning I'm not a teacher

  3. #3
    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.

  4. #4
    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.

  5. #5
    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.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    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

  7. #7
    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 : 2

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