• AVR Freaks

Hot!IOC question

Author
didierleplae
Senior Member
  • Total Posts : 164
  • Reward points : 0
  • Joined: 2019/03/31 16:57:50
  • Location: 0
  • Status: offline
2020/02/29 02:26:54 (permalink)
3 (2)

IOC question

As far as I understand, "interrupt on change" will cause the PIC to jump to an interrupt service routine, and then jump back to wherever it left off. 
But, what if I would want it to jump to a specific place afterward, like back to the start of my while(1) loop? 
#1

5 Replies Related Threads

    ric
    Super Member
    • Total Posts : 26124
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: IOC question 2020/02/29 03:19:54 (permalink)
    +1 (1)
    It will only "jump to an interrupt service routine" if you have the matching "IE" flag set.
    No, you can NOT have an interrupt service routine return to a different place.
    What you could do, is NOT set the IOCIE flag, and just check the IF flag at strategic places in your code, and restart your while loop if it is set.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    1and0
    Access is Denied
    • Total Posts : 10568
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: IOC question 2020/02/29 04:36:42 (permalink)
    +1 (1)
    ric
    No, you can NOT have an interrupt service routine return to a different place.

    For professionals only!  If PIC device allowed it, like PIC18, replace the TOS with new address. LOL
    #3
    ric
    Super Member
    • Total Posts : 26124
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: IOC question 2020/02/29 05:25:09 (permalink)
    0
    and expect nasty things to happen if you don't have a circular stack...
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    1and0
    Access is Denied
    • Total Posts : 10568
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: IOC question 2020/02/29 06:47:02 (permalink)
    +1 (1)
    That is why the professional only part. ;) I don't know why OP wanted to do that, but if I ever have such a need to handle something that fast with interrupt I'd probably do these in the ISR:
    • reset any and all things that can cause nasties
    • clear stack pointer STKPTR
    • branch to start of while loop with a GOTO
    which will discard all nested calls and context saving to start afresh. ;)
     
     
    @OP: I suggest you to do with Ric has suggested in Post #2.
     
    #5
    didierleplae
    Senior Member
    • Total Posts : 164
    • Reward points : 0
    • Joined: 2019/03/31 16:57:50
    • Location: 0
    • Status: offline
    Re: IOC question 2020/02/29 11:30:32 (permalink)
    0
    ric
    It will only "jump to an interrupt service routine" if you have the matching "IE" flag set.No, you can NOT have an interrupt service routine return to a different place.What you could do, is NOT set the IOCIE flag, and just check the IF flag at strategic places in your code, and restart your while loop if it is set. 


    Ok, thanks, I will try that out!
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5