Debugging PIC code with 3rd party compliers

Discussion in 'Embedded Systems and Microcontrollers' started by spinnaker, Dec 18, 2010.

  1. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    In another post someone mentioned GC Basic. There are a number of other 3rd party programming languages for BASIC, C and Pascal for the PIC.

    Do these compliers have a debugger that works with the PiC Kit 3?
     
  2. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    In debug mode PICkit3 must run from the MPLAB IDE.
    Most third party compilers can be plugged into and run from MPLAB so as long as the compiler will run under MPLAB then PICKit3 will work in both program and debug modes.
     
  3. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    So the ones that are stand alone like GC Basic would not work?

    Are you (or anyone aware) of a better IDE to replace MPLab but still allow debugging? I was thinking of something like HiTide that uses Eclipse. But last I checked HiTide was not compatible with the 8 bit PICs (or some kind of other limitation).
     
  4. AlexR

    Well-Known Member

    Jan 16, 2008
    735
    54
    I don't know much about Basic compilers but I know that most third party C compilers will plug into and run under MPLAB.

    As for other IDEs, as far as I know none of them will run PICKit3. They may have their own simulators or debuggers but they will not work with PICKit3. PICKit3 needs to run under MPLAB so it can download the correct version of software for the chip that is being programmed or debugged. Each time you program/debug a different chip type PICKit3 download its internal software to match the chip.
     
  5. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Most popular C compilers have an MPLAB IDE plugin so code can be debugged but it is a bit clumsy.

    I think the higher end BASIC languages also have MPLAB integration, but it is still not very smooth compared to the standalone program.

    Create an asm listing at compile time, and step through that in MPLAB. That makes it a bit better since the statements that created the code are added as comments in the .asm file.
     
  6. nickelflipper

    Active Member

    Jun 2, 2010
    280
    35
    spinnaker:
    This is how you would do it from GCBasic. I would use the GCBasic MPASM option too for MPLAB (I like the .lst file better), as opposed to the internal assembler, or GCASM (gputils). If using the 18fxxKxx series, then the internal assembler is a must.

    The compiled.asm file is in the GCBasic folder, and then just import that from MPLAB into the project. Once it's linked in, it will ask to rebuild the project for each successive compile instance. So almost hassle free?

    P.S. GCBasic is not case sensitive, so be sure the MPASM.exe (if you use it) has the case sensitive box unchecked.
     
  7. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,866
    988

    So then technically, you would be debugging ASM code instead of the native code?

    I really wish MPLab would move to Eclipse. I don't mind programming in C but the IDE could sure use improving.
     
  8. nickelflipper

    Active Member

    Jun 2, 2010
    280
    35
    Well isn't ASM the native code here? I am not sure where stepping thru a high level language program would have meaning, because behind each command would, or could be, multiple asm instructions.

    There is a MPLAB X IDE in beta, don't know anything about it, maybe more to your liking?
     
  9. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Sort of. Sometimes "What you meant to do and what is happening" are different, good example is with pointers in C.

    Still, you can skip from BASIC statement to the next one to check if the registers match what you thought they would. You look at the assembly in between if the statement you entered is doing something different than what you meant. Such as a test verses an assignment in C, etc.

    Most of these problems are found before you write to the IC. The In Circuit Debugging comes in useful when getting ADC readings and verifying inputs are what you expected them to be.
     
  10. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    Sorry should have said source code.

    Thanks for the tip on MPLAB X.
     
Loading...