Which interrupt ?


Results 1 to 5 of 5

Threaded View

  1. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Which interrupt ?

    Just thinking out loud here . . . when the interrupt (IOC) occurs you want to read the port, & save it to a temp variable. in your main loop read the variable & act early on, if your main loop is long and busy then check often. I would not act in the ISR unless critical, just to keep the ISR short & sweet, if it is critical, if micro second response is required then act there.
    example;
    Code:
    switchVar var byte     ' var to store port value
    doSomething var byte ' counter var
    
    main:
    do this . . . bla bla 'your code
    gosub Check
    do more . . .' more yourcode
    
    for doSomething = 0 to 50
    gosub check
    yourcode
    next doSomething
    
    morecode . . . 
    gosub check
    
    goto Main
    
    Check:
    if switchVar = 0 then
    return
    else
    do something with the information in switchVar
    switchVar = 0 ' clear the variable after work done
    endif
    
    return
    You could also read the interrupt flag bit to see if interrupt has come, esp if using PBP on interrupt. Asm interrupts are so fast, they would likely be cleared before you loop ever go there though. I am sure others have better solutions, but this will get you started.
    IN Conclusion:
    ISR
    read the port
    store port value in a var
    exit ISR 'assuming ISR clears IOC Flag
    do something with the information in your program
    Last edited by Archangel; - 7th July 2013 at 20:23.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. Need help with interrupt
    By mbox in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th August 2010, 16:48
  2. RX interrupt
    By Arciure in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th March 2010, 17:23
  3. on interrupt help
    By cphillips82 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th April 2008, 15:48
  4. always go to interrupt
    By savnik in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th March 2007, 03:31
  5. Replies: 0
    Last Post: - 27th August 2004, 07:20

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