is there a simple way make a condition true on a rising edge on an input


Closed Thread
Results 1 to 3 of 3
  1. #1
    EDWARD's Avatar
    EDWARD Guest

    Default is there a simple way make a condition true on a rising edge on an input

    is there a way to make a if then statement like this:

    IF rising edge is detected on portb.0 THEN

    do some code

    endif

    im trying to increment a varible by 1 every time it receves a low high transistion on input pin portb.0. the timing between of the signals could be from 10 to 500 ms. i cant have any long pauses.

  2. #2
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    Since you want to use PortB.0 you can check the interruptflag.
    Code:
    OPTION_REG.6 = 1       ' rising edge
    INTCON.1 = 0           ' reset the interruptflag
    
    IF INTCON.1 = 1 THEN
       INTCON.1 = 0        ' reset the interruptflag
       ' your code
    ENDIF

  3. #3
    EDWARD's Avatar
    EDWARD Guest


    Did you find this post helpful? Yes | No

    Default that works.

    well thats exctly what i needed. thank you very much.

    i was trying to run a chunk of code only when portb.0, on my 16f73 configured and set as an input, read a rising edge signal. as ingvar has shown i can use interrupts.



    'this part is only run once at the top of my program'

    OPTION_REG.6 = 1 ' rising edge
    INTCON.1 = 0 ' reset the interruptflag


    'this part is contained in a loop'

    IF INTCON.1 = 1 THEN
    INTCON.1 = 0 ' reset the interruptflag
    ' your code
    ENDIF

Similar Threads

  1. mS Timer
    By whmeade10 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th September 2020, 13:12
  2. Need help - Just want to make a simple switch using RF Modules
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 25th October 2009, 11:38
  3. AT/PS2 Keybord - PIC Interface?
    By Kamikaze47 in forum Code Examples
    Replies: 73
    Last Post: - 9th August 2009, 17:10
  4. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 02:50
  5. Best way to find a rising edge?
    By jcsquire in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 31st May 2006, 16:11

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