Measuring Period of a pulse


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2008
    Posts
    60

    Default Measuring Period of a pulse

    Hello does anyone have a example of code to measure the period of a pulse? Maybe using CCP or something? Thanks.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Measuring Period of a pulse

    Don't have example code, but start a timer, set portb interrupt, get the value of the timer in the interrupt service routine,
    reset the timer for the next pulse.

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: Measuring Period of a pulse

    I think you need to use the PULSIN command if you do not need interruptable operations.
    Code:
    PULSIN Pin,State,Var
    Measures pulse width on Pin.  If State is zero, the width of a low pulse
    is measured.  If State is one, the width of a high pulse is measured. 
    The measured width is placed in Var.  If the pulse edge never happens
    or the width of the pulse is too great to measure, Var is set to zero.
    Pin is automatically made an input.  Pin may be a constant, 0 - 15, or a
    variable that contains a number 0 - 15 (e.g. B0) or a pin name (e.g.
    PORTA.0).
    The resolution of PULSIN is dependent upon the oscillator frequency.  If
    a 4MHz oscillator is used, the pulse width is returned in 10us increments. 
    If a 20MHz oscillator is used, the pulse width will have a 2us resolution. 
    Defining an OSC value has no effect on PULSIN.  The resolution always
    changes with the actual oscillator speed.

  4. #4
    Join Date
    Nov 2008
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Measuring Period of a pulse

    Thanks for the replies.
    Regards
    CharlieM
    Using PBP3
    MCSPX

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Measuring Period of a pulse


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