Tracing code in MPLAB Sim


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2005
    Posts
    78

    Default Tracing code in MPLAB Sim

    I've got my PIC Bacic Pro compiler working inside MPLAB. So far, so good. My first 'Hello World' test code is blinking my LEDs on the PICKit board.

    HORAY!

    Next step is to back up and inspect the code, I've always counted on a code walk thru under the MPLAB Simulator as a necessary reality check.

    The question is what is the best way to set this up? The Disassembly listing would be nice, each Basic line is in there, commented in the code flow, but only a portion of the asm statements are there, the current line pointer can dissapear to somewhere in this 7,000+ line listing. The Program Memory window has every asm statement there, but not the basic comments.

    Both these windows can be open to see every Basic and asm stetement, but its a bit clumsy.

    Any other suggestions?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Here's a tip I don't think a lot of people using PBP are aware of. This lets you view the entire PBP program in pure assembler & even shows each sub-routines label.

    Download the latest version of MPLAB, and compile your code with MPASM.

    Start MPLAB, and select the target PIC you compiled for & osc speed.

    Click File, then Import. Locate the .COD file NOT the .hex file.

    Example: blink.bas was compiled. Locate & import blink.cod.

    Click View >> Program Memory. You'll see the full assembler file on-screen.

    Right click in the Program Memory window, roll down & click on Properties.

    Make sure there's a check mark next to Disassembly & Label, and move label to the top by highlighting Label, and cicking the Move Up button. This places each routies name or label on the left just like it would normally appear in your source code.

    Now you can simulate, watch everything happen, and even print the full assembly listing in a format you can read.

    You can't compile with PBP from within MPLAB doing it like this, but it's a lot easier to follow during simulation, and reading the assembler code PBP produces.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Thumbs up

    Nice tip Bruce!

  4. #4
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    While it is true you cannot compile with PBP from within MPLAB, you CAN use PBPW, which is the windows version of the PIC Basic Pro compiler. This means you can write, compile, simulate, and program your device all from the same IDE (and for those of us moving from MPLAB assembly, this is an environment we're quite familiar with).

    Make sure you've installed the MPLAB plug-in. When you're starting a new PBP project in MPLAB using the Project Wizard, just pick the "microEngineering PicBasic Toolsuite" ("microEngineering PicBasic Pro Toolsuite" if you have it) and browse for PBPW.EXE (not PBP.EXE).

    You will also get full text highlighting of your basic code.

    One thing I like is using MPLAB to help set configuration bits. Use the MPLAB configure bits menu to make the settings as you wish. The configuration word will be displayed under "Value." Then copy this number into your program like so:

    @ __config 0x3FC4 ; configuration bits

    No messy lookups for what function sets what bit. You will need to comment out the standard __config statement in the PBP .INC file or azn error will result. I've also added a message reminding me I've changed the .INC file in case later I assume I've set it.

    Including the COD file is a help, gives a bit more info to the Program Memory window. Still, I'll keep it and the Disassembly Listing window open for code walking. It helps to see which Basic line is being executed.

Similar Threads

  1. Replies: 1
    Last Post: - 19th February 2009, 13:35
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. MPLab SIM question
    By presario1425 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 3rd December 2007, 21:22
  5. Linker/COFF debugging in MPLAB SIM
    By RichardBowser in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th January 2007, 18:28

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts