Pulse Counter in Assembly


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Posts
    3

    Cool Pulse Counter in Assembly

    Can someone please help!

    I'm using picbasic pro and I want to insert an assembly language routine that can count a pulse using any I/O pin similar to the COUNT command in picbasic?

    The COUNT/PULSIN commands in picbasic are too slow and hold up my program The Timer interrupt pin(s) are already being used (board is already layed out) so thats out of the question.

    thanks in advance

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    The best pins to use are the PORTB pins that offer a hardware interrupt function. If you can't use those, you will have to rely on a timer - but using that approach, there is a limit to how fast/short the pulses can be.

    Therefore, it would be nice to know.

    Can you use the PORTB interrupt pins?
    What is the minimum high and low time of your pulses?
    Charles Linquist

  3. #3
    Join Date
    Mar 2007
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    I am using the 18F6722, and the pulses are being measured on PORTE, Pin 7. The pulse is roughly 340ms

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Your pulses seem slow enough that you could do that with a PBP interrupt.
    Look at Darrel Taylor's Instant Interrupts.

    You could set up a 65mSec (or so) TMR0 interrrupt, and in the ISR, read the state of the input pin, XOR it with the last value you read from that pin (something like "oldpinvalue"), if the XOR value is "1", increment a counter. Then copy the pin's state to oldpinvalue in preparation for the next interrupt.

    Since you have a (more or less) precision timer going with the interrupt, you will know exactly how many changes (pulses X 2) you got in any given time interval.
    Charles Linquist

Similar Threads

  1. Pulse Counter
    By srspinho in forum Code Examples
    Replies: 13
    Last Post: - 5th May 2012, 22:56
  2. Pulse Capture and byte building
    By boroko in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st July 2009, 02:59
  3. Need help with a pulse counter project PIC18F2620
    By blackrider in forum Schematics
    Replies: 1
    Last Post: - 29th April 2009, 01:08
  4. Replies: 3
    Last Post: - 13th September 2008, 18:40
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27

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