Hot!I2C Driver Exception on PIC32MZEF

Author
Johnny0099
Super Member
  • Total Posts : 146
  • Reward points : 0
  • Joined: 2015/06/20 00:33:20
  • Location: 0
  • Status: offline
2018/02/13 18:18:24 (permalink)
0

I2C Driver Exception on PIC32MZEF

I'm using PIC32MZEF Rev. B1 (I2C hardware module that seems to be fixed in this revision) and I2C Harmony Driver with 2x I2C buses and multiple clients on the firts I2C istance. I'm getting the following exception on I2C_ReceivedByteGet_Default in function DRV_I2C_Tasks.
 
This happens once every hour when system is running, more or less.
 
Sometimes the exception is pointing to I2C_TransmitterByteSend_Default in DRV_I2C_Tasks.
 
Any idea on how to fix this situation? Did someone experienced the same issue?
 
Harmony Version: 2.03b
Compiler: XC32 v1.44
 
Interrupt priority seems to affect the beaviour of both I2C. This is how it's set now (that gives the best performance):
 
1st istance: Priority 5, SubPriority 2
2nd istance: Priority 5, SubPriority 1

Attached Image(s)

#1

13 Replies Related Threads

    GDA
    Starting Member
    • Total Posts : 73
    • Reward points : 0
    • Joined: 2015/08/31 16:46:40
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/14 11:40:30 (permalink)
    0
    That bug sounds like a very old bug where the I2C_MODULE_INDEX parameter was being corrupted before the call.  Can you get the value of I2CxRCV when the bug occurs?
    #2
    Johnny0099
    Super Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/06/20 00:33:20
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/14 12:04:25 (permalink)
    0
    Let me run again until the exception occurs, I will get in Watch both I2C1RCV and I2C5RCV and see If I can get the values when the debug is halted from the exception. When in run mode (no debug) the MPU reset. Is there any other test that you suggest this time?
     
    Is there any particular reason that makes the I2C_MODULE_INDEX parameter to be corrupted? Any workaround?
    post edited by Johnny0099 - 2018/02/14 12:12:17
    #3
    GDA
    Starting Member
    • Total Posts : 73
    • Reward points : 0
    • Joined: 2015/08/31 16:46:40
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/14 12:28:07 (permalink)
    0
    Well, yes.  The work around is not to corrupt it.  ;)
     
    I am making some assumptions, of course.  If I am right, then you will see something like a 0 or perhaps a 1 (basically the number of the I2C peripheral you are using) rather than the address to the SFR registers of that I2C module.
     
    The only other test I can recommend is to use an exception handler and set a break point there.  In there, some registers should give you more information about the specific exception.
     
    You can look up how to overwrite the exception handler in the MPLAB® XC32 User's Guide.
     
    You should, however, get a breakpoint in the exception handler if your running in debug mode.
    #4
    Johnny0099
    Super Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/06/20 00:33:20
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/14 12:47:39 (permalink)
    0
    I'm getting this in the variable windows (see the pics) when running in debug mode. When the exception happens the Call Stack windows shows the address where the exception happened and is pointing to I2C_ReceivedByteGet_Default.
    post edited by Johnny0099 - 2018/02/14 12:52:07

    Attached Image(s)

    #5
    GDA
    Starting Member
    • Total Posts : 73
    • Reward points : 0
    • Joined: 2015/08/31 16:46:40
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/14 13:05:23 (permalink)
    0
    As you can see, the index variable does contain the 0xBf82000 value.  So, it is not getting corrupted.  Sorry that was a red herring.
     
    I think it is time we set a break point in the exception handler and see just what kind of an exception is happening.  What happens if you let the debugger step from here?
     
    Also, it might help if you could determine precisely which line in the driver is calling I2C_ReceivedByteGet.
     
    Let me check my other assumptions:
     
    1) I assume that when you say it runs for an hour, that it communicates with all of the slaves?  The communication which is failing is not the first time it is attempting to talk to a particular slave or anything like that, right?
     
    2) the error occurs long after the driver and I2C peripheral are initialized.  This does not happen after a sleep or anything like that?
     
     
    #6
    Johnny0099
    Super Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/06/20 00:33:20
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/14 13:14:57 (permalink)
    0
    Thank you GDA. I will set a BP in the exception handler and launch it now. Will let you know as soon as the exception happen.
     
    The assumpions 1 and 2 are correct
     
    1) The MPU comunicates continuolsy with both I2C buses and with all peropherals, none excluded. Each pheripheral is polled at the same time interval.
     
    2) Yes, the error occurs long after the driver and I2C peripheral are initialized, I'm not using neither sleep or anything like that that may stop/delay the I2C bus transfer.
    #7
    GDA
    Starting Member
    • Total Posts : 73
    • Reward points : 0
    • Joined: 2015/08/31 16:46:40
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/14 13:31:29 (permalink)
    0
    What other peripherals are you using.  I might need to look further afield for possibilities.
     
    UARTS?  PMP?  SPI?  DMA?
    #8
    Johnny0099
    Super Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/06/20 00:33:20
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/14 14:01:35 (permalink)
    0
    Ehhh, a lot of peripherals other than I2C!
     
    2xUARTS
    1xSPI
    1xI2S
    5xDMA (4 with ADC and 1 with I2S)
    4xTIMER
     
    I can also try to run only the Apps that are using I2C avoiding other peripherals.
     
    Program in Debug Mode stops showing the Stack Call, but the break point in the exception handler is not fired. This sound strange to me..

    Attached Image(s)

    #9
    GDA
    Starting Member
    • Total Posts : 73
    • Reward points : 0
    • Joined: 2015/08/31 16:46:40
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/14 14:56:17 (permalink)
    0
    The next time you get a chance, take a look at the exception register and lets see if the status is in there.
     
     
    #10
    Johnny0099
    Super Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/06/20 00:33:20
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/28 01:46:19 (permalink)
    0
    I'm back on this issue, trying to figure out what is happening inside my PIC32MZ, I have the following new elements:
     
    1) I've increased the clock frequency of both I2C buses to 400 Khz hoping to have more frequent exceptions (it was 50 Khz before, and was getting one exception every 6/8 hours), and now I'm getting exceptions at different addresses. Screen shots of the exception is in attachment. I can read the values of EPC, Status and Cause registers:
     
    EXCEPTION 1
    - Status has both ERL and EXL bit set
    - Cause seems to be TLB exception (load or instruction fetch)
     
    Furthermore, at 400 Khz one of the I2C was stuck. I've decreased the frequency to 100 Khz and I'm still waiting for next exception :-)

    Attached Image(s)

    #11
    Johnny0099
    Super Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/06/20 00:33:20
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/28 06:50:28 (permalink)
    0
    Now debugger halted with no information on Call Stack neither breakpoints on exception handler was reached. These are exception registers:
     
    EPC: 0x9D0120A0
    Cause: 0x00800000
    Status: 0x00400005
     
    How to debug this?
     
    post edited by Johnny0099 - 2018/02/28 06:52:36
    #12
    Johnny0099
    Super Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/06/20 00:33:20
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/02/28 11:39:10 (permalink)
    0
    Another exception:
     
    EPC: 0x9D0389DC
    Cause: 0x00400006
    Status: 0x0080000C

    Call Stack: Runtime exception @ PC address 0x9d0389dc in function: __cmpdi2 ( )  at  /build/bamboo/xml-data/build-dir/XC32-TBC-BLD/builddir/pic32m-source/src48x/gcc/libgcc/libgcc2.c : 1193
     
    Does someone had similare exception? How to handle it?
    #13
    Johnny0099
    Super Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/06/20 00:33:20
    • Location: 0
    • Status: offline
    Re: I2C Driver Exception on PIC32MZEF 2018/03/05 14:11:27 (permalink)
    0
    Just right now I'm getting another exception (the same old one): 

    Call stack is pointing here: 

    PLIB_TEMPLATE uint8_t I2C_ReceivedByteGet_Default( I2C_MODULE_ID index ) 

    volatile i2c_register_t *regs = (i2c_register_t *)index; 

    return (uint8_t)regs->I2CxRCV; 


    Cause = 0x0080000C - TLB exeption (store) 
    Status = 0x00400006 (both EXL and ERL are set and BEV = 1) 
     
    GDA, any idea?
     
    post edited by Johnny0099 - 2018/03/05 15:58:21

    Attached Image(s)

    #14
    Jump to:
    © 2018 APG vNext Commercial Version 4.5