Maximum frequency output from a PIC


Closed Thread
Results 1 to 40 of 69

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,132


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Quote Originally Posted by HenrikOlsson View Post
    if everything fits within the same page (Page 0) then that same GOSUB now takes 3 instructions instead of 2. Go figure...
    I think it is because it does not know if it is in page 0 or 1 or else, so a test must be done first?

    Ioannis

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi,
    Here's a link to the thread on MELABS forum. Darrel posted code there which he used to demonstrate, I'm sure you can disassemble that.

    /Henrik.

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    699


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    Here's a link to the thread on MELABS forum. Darrel posted code there which he used to demonstrate, I'm sure you can disassemble that.

    /Henrik.
    Hmm, I knew that the used programming space goes down, but I had no idea that it had to do with the GOSUBs. Also, it is good to know that the enhanced chips do not have this issue.
    "No one is completely worthless. They can always serve as a bad example."

    Anonymous

  4. #4
    Join Date
    Oct 2012
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi Team,

    I am using the setup from post #43 and I need a clarification on how the duty cycle setting works.
    If I understood the data sheet correctly for a 16 MHz main clock and an output frequency of 250 KHz I have access to 16 steps of duty cycle.
    Also the manual states that you can use CCPR1L which is 8 bit wide and CCP1CON.5 plus CCP1CON.4 so you have access to a 10 bit wide setting.

    My question is who keeps track of individual values and their place in the 10 bit variable.
    Is the user supposed to do the logic or PBP takes care of it?
    For example if I use something like this:

    CCPR1L = 5
    CCP1CON.5 = 1 (an 0 means 0 and an 1 means 2)
    CCP1CON.4= 0 (an 0 means 0 and an 1 means 1)

    Is the result 7 so we just add the two values or is it 21 which comes from 5 shifted twice and add 2 from CCP1CON.5 ?

    Does one have to pick only multiple of 4 when choosing CCPR1L or whatever value is given is taken as a 10 bit value and added to CCP1CON 4 and 5?


    Regards,

    Nick

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Hi,
    With 16MHz main clock there are three different prescaler ratios all giving you 250kHz but different number of bits of resolution.
    If you set prescaler to 1:2 and load PR2 with 3 then you'll get 250kHz and 5 bits of resolution (not 5 "full" bits actually), ie you can set the dutycycle value anywhere between 0 and 16.

    If you set the prescaler to 1:1 and load PR2 with 15 you'll get the same frequency but now you've got better resolution, 0-64 instead of 0-16.

    Now, just write out whatever value you want in binary as a 10bit value: %0000010110
    The two least significant bits goes to CCP1CON.5 and CCP1CON.4 and the remaining 8 bits goes to CCPR1L, in this case (as in your example) the result would be 21 which would result in either 100% or ~20% depending on the prescaler and PR2 setting as outlined above.

    /Henrik.

  6. #6
    Join Date
    Oct 2012
    Posts
    82


    Did you find this post helpful? Yes | No

    Default Re: Maximum frequency output from a PIC

    Thank you Henrik.
    It makes more sense to me now.

    Regards,

    Nick

Similar Threads

  1. internal TMR for frequency output
    By Samoele in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th January 2009, 09:38
  2. How to calculate PIC sampling frequency
    By minmin in forum General
    Replies: 1
    Last Post: - 26th September 2006, 18:02
  3. Replies: 2
    Last Post: - 20th January 2006, 21:09
  4. Maximum frequency count on 16F628/4MHz
    By solara in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 23rd May 2005, 10:38
  5. Low frequency output
    By barkerben in forum General
    Replies: 5
    Last Post: - 16th November 2004, 15:25

Members who have read this thread : 0

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