• AVR Freaks

Hot!interrupts and exceptions

Author
skeev
New Member
  • Total Posts : 15
  • Reward points : 0
  • Joined: 2018/11/08 10:27:03
  • Location: 0
  • Status: offline
2019/08/23 12:09:41 (permalink)
0

interrupts and exceptions

It seems to me that this should be in a FAQ somewhere,
but I've yet to find it.
A pointer to it would be good.
 
How do PIC32s (e.g. my PIC32MX795F512L)
and xc32-gcc handle interrupts and exceptions?
I've got MPLAB® XC32 C/C++ Compiler User’s Guide
and PIC32MX Family Reference Manual.
I'm still confused.
 
CUG mentions  void _general_exception_handler(void)
for handling general exceptions.
It also mentions
void _simple_tlb_refill_exception_handler(void) and
void _cache_err_exception_handler(void) .
Are the latter two not general exceptions?
 
I inherited some code and would like to find
out what kind of exception it's producing.
I'd rather not code handlers at random and
see which one's seem to work.
#1

16 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 6187
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: interrupts and exceptions 2019/08/23 12:18:52 (permalink)
    +1 (1)
    I write code to handle each of the possible exceptions to make my life easier finding who caused what and where
    #2
    Jim Nickerson
    User 452
    • Total Posts : 6187
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: interrupts and exceptions 2019/08/23 12:25:38 (permalink)
    0
    This works in debug mode but when running I store the data ( breadcrumbs ) to dump to my serial debug on the restart
    #3
    skeev
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2018/11/08 10:27:03
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/23 12:33:05 (permalink)
    0
    In production, there shouldn't be any exceptions.
    If there are, a software reset is probably the right thing to do.
    I don't even know the names of the handlers I'd
    have to write to have one for each exception.
    I expect there are more than the ones I listed.
     
    What happens if one has both _general_exception_handler
    and _simple_tlb_refill_exception_handler,
    but not _cache_err_exception_handler ?
    What is the mechanism?
     
    Is there a FAQ for this?
    #4
    skeev
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2018/11/08 10:27:03
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/23 12:34:53 (permalink)
    0
    BTW I can't get to debug mode.
    See my other thread.
     
    #5
    Jim Nickerson
    User 452
    • Total Posts : 6187
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: interrupts and exceptions 2019/08/23 12:37:55 (permalink)
    0
    since the first exception that happens resets the processor.....
    I have found reading the fine manuals many times helps.
    learning this processor does take a while.
    though there "shouldn't be any exceptions " there will always be the exception you have not thought of.......
    how did you manage to "inherit" software that throws exceptions ?
    #6
    Jim Nickerson
    User 452
    • Total Posts : 6187
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: interrupts and exceptions 2019/08/23 12:39:16 (permalink)
    0
    skeev
    BTW I can't get to debug mode.
    See my other thread.
     


    then how do you know there are exceptions ?
    how would I know there is another associated thread ?
    #7
    skeev
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2018/11/08 10:27:03
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/23 12:54:02 (permalink)
    0
    Trying to figure out what the FM is supposed
    to be stating can be quite a challenge sometimes.
     
    The I2C code I inherited more or less worked,
    but was very sensitive to changes.
    During a small refactoring,
    what would have been a call to a static function,
    had to be a macro reference.
    Experiments suggested that the problem was not time,
    but I still do not know what it is.
    I've been whittling away at the code to discover
    how small I can make it and still have said problem.
    The most recent whittle produced the exception I am trying to find. 
    #8
    skeev
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2018/11/08 10:27:03
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/23 13:07:54 (permalink)
    0
    JANickerson
    skeev
    BTW I can't get to debug mode.
    See my other thread.
     


    then how do you know there are exceptions ?
    Strictly speaking, I suppose I don't.
     
    I'm getting software resets.
    The processor is in single-vector mode and there is a handler,
    so they are not caused by unhandled interrupts.
    My inference is unhandled exceptions.

    how would I know there is another associated thread ?
    Not until I told you. 
    I only have one other and it's in this forum:
    The program file could not be loaded: Invalid file offset requested
     
    #9
    Jim Nickerson
    User 452
    • Total Posts : 6187
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: interrupts and exceptions 2019/08/24 09:42:34 (permalink)
    +1 (1)
    The "RCON" register is your friend.
    Check the "RCON" register on start up and report unexpected things and handle them.
    #10
    NKurzman
    A Guy on the Net
    • Total Posts : 17719
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/24 22:05:49 (permalink)
    +2 (2)
    Make a sample project in Harmony. Enable the exception handling, You will get code for all of the exception handlers. Copied into your project. The most common exception is an unaligned access. By using a pointer on incorrectly aligned memory
    #11
    Jim Nickerson
    User 452
    • Total Posts : 6187
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: interrupts and exceptions 2019/08/25 07:30:09 (permalink)
    +2 (2)
    NKurzman
    Make a sample project in Harmony. Enable the exception handling, You will get code for all of the exception handlers. Copied into your project. The most common exception is an unaligned access. By using a pointer on incorrectly aligned memory

    great tip on the use of Harmony
    #12
    skeev
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2018/11/08 10:27:03
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/27 06:57:34 (permalink)
    0
    NKurzmanMake a sample project in Harmony. Enable the exception handling, You will get code for all of the exception handlers. Copied into your project. The most common exception is an unaligned access. By using a pointer on incorrectly aligned memory
    Thanks.  I'll do that.


    Also, what does ExcCode 0 mean?
    Documentation says interrupt.
    Huh?
    I'd thought interrupt != exception.
    #13
    andersm
    Super Member
    • Total Posts : 2637
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/27 08:26:15 (permalink)
    0
    From the point of view of the processor, interrupts are one type of exception.
    #14
    skeev
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2018/11/08 10:27:03
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/27 09:06:49 (permalink)
    0
    andersmFrom the point of view of the processor, interrupts are one type of exception.
    I realize they are treated similarly, but they have separate handlers.
    That is why I do not understand how one gets an exception whose cause is interrupt.
     
    post edited by skeev - 2019/08/27 09:10:48
    #15
    andersm
    Super Member
    • Total Posts : 2637
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/27 10:16:51 (permalink)
    0
    Originally there was no separate interrupt vector. Even today, the Cause.IV bit selects which vector is used for interrupts (I'm not sure if it works on PIC32Ms, due to how they implement single-vector mode).
    #16
    skeev
    New Member
    • Total Posts : 15
    • Reward points : 0
    • Joined: 2018/11/08 10:27:03
    • Location: 0
    • Status: offline
    Re: interrupts and exceptions 2019/08/27 11:54:18 (permalink)
    0
    I've read that single-vector mode is done by forcing
    all the individual interrupt vectors to be the same.
    #17
    Jump to:
    © 2019 APG vNext Commercial Version 4.5