• AVR Freaks

Hot!Can't debug with MPLAB X, keep getting "An Error occured while running"

Page: 12 > Showing page 1 of 2
Author
andrew_ar
New Member
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2015/02/03 07:52:11
  • Location: 0
  • Status: offline
2016/10/07 04:42:23 (permalink)
0

Can't debug with MPLAB X, keep getting "An Error occured while running"

I am trying to use MPLAB X 3.40 to debug code I have written for a PIC24FV16KA301. I am using a Real ICE.
My code makes use of FreeRTOS.
 
I can compile OK and program the microcontroller with no debugging.  That all works fine.  I can also program using the debug option and then halt the execution using either a breakpoint or the pause button on the toolbar.  However, if I then try to restart the execution (play button) or step through the code or "run to cursor" etc, I immediately get the error "An Error occurred while running".
 
When I started and didn't have much code, this did not happen. I am wondering if I am trying to run too complex a program on the 24FV16KA301 core for the debugger to work.  Anyway, this is driving me mad and I have resorted to other very limited means of debugging.
 
I notice that there were some discussions on this error sometime ago, but nothing recently.  If there is a fix or explanation, I would be grateful to know.  Many thanks in advance.
 
Andrew
#1

21 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 18859
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/07 06:43:48 (permalink)
    +1 (1)
    I doubt your code is too complicated for the debugger.
    Do you have the exception traps in your code? Are you getting an exception?
    How long is the cable from the real ice to the pic?
    Does the target have AC, relays,or anything else that can disturb the connection.
    post edited by NKurzman - 2016/10/07 09:38:52
    #2
    andrew_ar
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/02/03 07:52:11
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/07 09:23:32 (permalink)
    0
    Hi,
    Many thanks for your quick reply.
    I don't have exception traps in my code - will look at doing that next.  I do have configASSERTS (FreeRTOS debugging facility), but none of these are catching errors, or at least not now that have I fixed two bugs.
    I am using the standard cable from the Real ICE to the pic - 6 inches.  Out of curiosity, I also tried the high speed cable with tx and rx receiver boards - this made no difference and the problem remained.  There are no relays on my board and I am powering the board with a DC supply. At present there is only the PIC and an LCD screen (no backlight).
     
    I will investigate putting exception traps into my code, but don't hold out much hope of that shedding any light on the problem.
     
    Many thanks for your suggestions, anyone else got any hints?
    #3
    andrew_ar
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/02/03 07:52:11
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/08 07:30:07 (permalink)
    0
    Well I added trap code as suggested, but no exceptions are happening.  If I pause the execution in debug mode without any breakpoints, the progam always stops at a different place each time.  This implies that my code is running and there is a problem with the Real ICE or MPLAB X.  The Real ICE cost me a lot of money and I am beginning to seriously regret choosing Microchip.  What is the use of an expensive piece of kit if it doesn't work and gives no helpful information about what is wrong?
     
    I have tried producing an MPLAB.xml file, but interpreting that using a text editor is very difficult.  Near the end of that file there is a line which has the words "MCDebugger: Failed request to read target memory".  Maybe this is a clue, but how I don't know.  Is there any other way to find out more information about the "An Error occurred while running" message?
     
    Any help would be gratefully appreciated.
    #4
    andrew_ar
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/02/03 07:52:11
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/10 02:52:59 (permalink)
    +1 (1)
    Well I managed to debug my code, but the debugger is definitely not working correctly.  If I insert a Nop where I want to look at variables and place a breakpoint there then I can get information.  But the step into, over, play functions still not not work and keep causing this error.
     
    It's not at all satisfactory and I am not happy with MPLAB X.
     
    Anyhow, I am able to continue with my project now.
    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 18859
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/10 05:57:00 (permalink)
    +2 (2)
    Did you look at the debug limitations?
    Real ICE is not a real ice it is a debugger.
    The need to add NOPs can be due to the optimizer leaving no code for a specific C line of code. Or due to break point skidding.
    #6
    andrew_ar
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/02/03 07:52:11
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/11 13:58:38 (permalink)
    +1 (1)
    I am getting breakpoint skidding.  A tad annoying, but I can live with that.
    I have looked through the debug limitations.  I'm not using any optimisation, but I am using the "Isolate each function in a section" and "Remove unused sections" options.  This is because the FreeRTOS files contain many functions which I am not using in this particular application.  Unless these options are ticked the code size is too large for the program memory.  Would telling the compiler/linker to cut out unused code cause the debugger not to work correctly?
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 18859
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/11 14:17:19 (permalink)
    +1 (1)
    The question becomes optimization.
    You dont want to force the compiler not to optimize because it makes your code bigger.

    For skidding add a few nops()after the line so it has a place to skid.
    NOPs also make a good breakpoint target if you can't set a break point.
    Static/global/volatile will force the compiler not to optimize away you variable.
    Of force remove the these modifications after you are done.
    #8
    GeorgePauley
    Moderator
    • Total Posts : 1261
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/11 15:04:36 (permalink)
    +1 (1)
    I have no clue about the main topic of this thread, but if you switch to software breakpoints there will be no skidding.
    #9
    andrew_ar
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/02/03 07:52:11
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/13 08:52:46 (permalink)
    0
    Thanks for your replies.  I decided to desolder the PIC from the board and replace it with a PIC24FV32KA301 - exactly the same as the previous one, but with twice the program memory.  I then unticked the selections detailed above and tried to debug using the REAL ICE again.  Exactly the same problem occurred.  There is now just over half of the program memory free even without removing unused sections from the compiled code, so no problem there.
     
    I am stumped to know what to do.  I am making progress with my project, but finding and eradicating bugs is much more time consuming without being able to step through the code.
     
    Regarding software breakpoints, the documentation warns that using them will reduce the endurance of a device.  How serious is this?  How many programming cycles before the PIC dies?
     
    Many thanks.
    #10
    NKurzman
    A Guy on the Net
    • Total Posts : 18859
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/13 10:34:51 (permalink)
    +1 (1)
    The Chip Data sheet tells you how many cycle it can take .
    Every use of the break-point may be a cycle.
     
     Nops() did not help using regular breakpoints?
    #11
    jarin
    Super Member
    • Total Posts : 848
    • Reward points : 0
    • Joined: 2005/05/23 13:50:02
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/13 15:44:57 (permalink)
    +1 (1)
    I experienced "problems with debugger" - ie. target freezing or randomly exiting debugging when my hardware had fault - broken decoupling capacitor on internal regulator feeding MCU core.
    I'm not saying this is exactly your problem, but just an idea to check out.

    Jaromir Sukuba, Bratislava, Slovakia
    http://jaromir.xf.cz/  - open source PIC18 debugger.
    #12
    andrew_ar
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/02/03 07:52:11
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/14 07:43:20 (permalink)
    +1 (1)
    Yes, I am inserting Nops() for use with hardware breakpoints.  Skidding is usually 3 Nops(), settling on the third.  I'm not too bothered about that - it's easy to insert Nops() temporarily.
     
    Regarding the programming cycles, I take it you mean each software breakpoint results in one more programming cycle than would otherwise have occurred.  I see the datasheet states a minimum of 10,000 cycles for the flash.  Hopefully I'll not get anywhere near that.  I'm sticking to using hardware breakpoints just in case.
     
    I have accepted that progress is going to be slow without being able to step through code.  I might be able to acquire a logic analyser and debug using that on some spare IO pins.
    #13
    andrew_ar
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/02/03 07:52:11
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/14 07:45:38 (permalink)
    0
    Thanks - I've already scrutinised the board under a microscope.  Can't be certain, but I'm pretty sure all components are OK.  I think it may be a driver issue on my computer.  Anyway, I have now got the LCD working on my board, so can use that to display limited debug info.
     
    #14
    Eric Christenson
    Super Member
    • Total Posts : 78
    • Reward points : 0
    • Joined: 2016/07/07 20:51:22
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/15 21:06:20 (permalink)
    +1 (1)
    Umm, any RTOS is going to need multiple stacks.  Have you verified that the extra stack space required by the breakpoints, (and the interrupts) isn't causing your system to crash?  I'm also a user of FreeRTOS.
     
    #15
    andrew_ar
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/02/03 07:52:11
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/10/16 10:02:29 (permalink)
    0
    Thanks for your reply an mentioning that you use FreeRTOS.
     
    I realise that 2K of RAM is not much when running FreeRTOS, but more memory means using a different PIC family, a larger chip in an already tight space, more power consumption etc.  I have configCHECK_FOR_STACK_OVERFLOW set to 2 in FreeRTOSConfig.h, which is not currently trapping anything.  I have also had traps to catch things as per Microchip's reference manual, again not trapping anything.
     
    I understand that such mechanisms are not foolproof and that shortage of stack could be causing crashes.  Maybe there is something silent going on.  The code I have written works fine without the debugger, it's just that adding new code is time consuming as the debugger doesn't allow stepping.  Now I have the LCD working, I can probably use that instead for the rest of the development.
    #16
    schneiderj
    Super Member
    • Total Posts : 497
    • Reward points : 0
    • Joined: 2008/01/19 07:46:49
    • Location: France, close to Paris
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/11/22 14:27:56 (permalink)
    0
    Hello,
     
    did you a chance to solve your issue ? I have one incredibly close to yours !
     
    Thanks you for your answer.
    Jean-Marie
    #17
    andrew_ar
    New Member
    • Total Posts : 16
    • Reward points : 0
    • Joined: 2015/02/03 07:52:11
    • Location: 0
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/11/23 10:55:49 (permalink)
    +1 (1)
    Hello,
    Interesting that you are getting a similar problem.  In short, no I didn't find a solution and ended up debugging using the LCD on the target board.  I'm now working on the next revision of our product, and have decided to change to using a PIC32 device instead.  The debugger is now working much better.  A bit annoying though, as this application only requires a 16 bit microcontroller.  I did manage to establish that the debugger worked fine on the PIC24 when FreeRTOS was disabled.
     
    Sorry to be of little help...hope you manage to debug your code!
     
    Andrew
    #18
    schneiderj
    Super Member
    • Total Posts : 497
    • Reward points : 0
    • Joined: 2008/01/19 07:46:49
    • Location: France, close to Paris
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/11/24 05:51:04 (permalink)
    +1 (1)
    Hello,
     
    effectively, you don't help me a lot. But now I know that I am not alone !!
     
    Jean-Marie
    #19
    schneiderj
    Super Member
    • Total Posts : 497
    • Reward points : 0
    • Joined: 2008/01/19 07:46:49
    • Location: France, close to Paris
    • Status: offline
    Re: Can't debug with MPLAB X, keep getting "An Error occured while running" 2016/11/24 14:45:58 (permalink)
    0
    Hello,
     
    I probably read all messages of the forum on that issue. I try one suggestion from RISC : reseting the REAL ICE from Project Properties. And from 3 hours I am able to debug without issue, and futher more I found the bug I had in my program !!
     
    But till the next time probably mad: mad.
     
    Jean-Marie
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2020 APG vNext Commercial Version 4.5