Looking at pic basic pro symbol values in mplab 8.15a simulator


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2009
    Location
    Pittsburgh, PA
    Posts
    17

    Exclamation Looking at pic basic pro symbol values in mplab 8.15a simulator

    Hi, I've searched the forums, read the mplab help and read many other posts elsewhere but can't find the answer to this simple question.

    When stepping through the mplab stimulus simulator with a pic basic pro program I cannot see my own local variable content.

    My thoughts as to why this is are:
    1. Could be it's supposed to be this way because it's not C. For example from this link I copied this text regarding viewing symbols:

      12.3 View Variables
      You can see the values of variables when the simulation is halted by putting the mouse cursor over the name of the variable in the source file. A tool tip like display will show the current value of the variable (this is called mouse over).

      The values in the watch window do not get updated when the program is running. Only when the program execution halts will they get refreshed. The values are displayed in red when its content changed.


      In my case I see none of this behavior. I also see nothing in the Symbols tab of the workspace. The documentation says the tab is populated using a third party tool called ctags which does not list pic basic pro as a language it can process.
    2. I've missed some step that someone here will now enlighten me on.

    The program compiles properly with no errors and all the appropriate files like .COD are generated. I can step through the code and see the special registers get their values changed ok.

    Thanks in advance.

  2. #2
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default

    Mplab stimulus simulator and in general the IDE has nothing to do with your program in Basic. You will never see what is happening in your program once it is compiled (virtually re-writen by the compiler in assembly).

    You see the variables only if they are from an assembly program or if Melabs ever permit this to happen through special plug in for Mplab.

    Till then, the only thing you can monitgor are the internal registers of the PIC that Mplab can directly show you. For example, if you want to increment Data RAM location $10 for every button press, then you can see the register $10 but not if you name it like My_Variable as it is not easy to find which register this maps to. Maybe others can help you to dig deep into the produced from compiler files to find the infos you seek...

    Ioannis

  3. #3
    Join Date
    Apr 2009
    Location
    Pittsburgh, PA
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Thanks Ioannis. Are you saying this from experience by any chance? I have installed the plugin you mention, and C programs clearly will show variables I mention since the quote I included is from a tutorial about the IDE showing the variable values.

    It seems to defeat the purpose of having a simulator you can step through but not see the variables as they change from line to line IMHO .

    Having said that, maybe supporting picbasic was just an afterthought and it's not fully supported yet (since you have to take manual steps to configure the IDE to generate picbasic projects).

    PS I should add I'm a programmer by trade so I'm familiar with the way things should work (in an ideal world), and all the behind-the-scenes jiggery-pokery that takes us from source code to binary.

    Quote Originally Posted by Ioannis View Post
    Mplab stimulus simulator and in general the IDE has nothing to do with your program in Basic. You will never see what is happening in your program once it is compiled (virtually re-writen by the compiler in assembly).

    You see the variables only if they are from an assembly program or if Melabs ever permit this to happen through special plug in for Mplab.

    Till then, the only thing you can monitgor are the internal registers of the PIC that Mplab can directly show you. For example, if you want to increment Data RAM location $10 for every button press, then you can see the register $10 but not if you name it like My_Variable as it is not easy to find which register this maps to. Maybe others can help you to dig deep into the produced from compiler files to find the infos you seek...

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Have you tried opening the watch window, and selecting your variables?

    It works fine for me. Never tried mouseover, but I definitely can watch variables change
    when I have the watch window open. And they change as the PBP program runs. It doesn't
    need to be stopped before they update.
    Attached Images Attached Images  
    Regards,

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

  5. #5
    Join Date
    Apr 2009
    Location
    Pittsburgh, PA
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Hey Bruce, sadly yes that's the window that I add the variables to but it always says 'value not found'. Do you have the Symbols tab in the workspace window populated with variables, functions etc? That's the other tab in the window that lists all the source code in the project.

    Thanks again.

    Quote Originally Posted by Bruce View Post
    Have you tried opening the watch window, and selecting your variables?

    It works fine for me. Never tried mouseover, but I definitely can watch variables change
    when I have the watch window open. And they change as the PBP program runs. It doesn't
    need to be stopped before they update.

  6. #6
    Join Date
    Sep 2007
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    The variables you declared in the PBP program should appear in the watch window Add Symbol dropdown, but an underscore "_" will be appended in front of the name. ("myvar" shows as "_myvar".) The exception to this are BIT-variables, which will not show by name.

    In the build options for the source file, make sure that "Use MPASM Assembler" and "Source-level Debug" are checked.

    You will need to specify the type of variable by right-clicking in the watch window after you add the variable. All variables are displayed as bytes by default.
    Charles Leo
    microEngineering Labs, Inc.
    http://melabs.com

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Looks like you can go to File, then Import, then selected the file.cod file, and then you can select your variables. Very nice Bruce, I did not know that either.

    <img>http://www.picbasic.co.uk/forum/attachment.php?attachmentid=3393</img>
    Attached Images Attached Images  
    http://www.scalerobotics.com

  8. #8
    Join Date
    Apr 2009
    Location
    Pittsburgh, PA
    Posts
    17


    Did you find this post helpful? Yes | No

    Default

    Excellent thanks Charles_Leo, scalerobotics and Bruce.

    I look forward to trying that when I get home tonight and tracking down the relevant part of the documentation that I might have missed.

    I also look forward to contributing to the forum when I get up to speed.

    Cheers.

  9. #9
    Join Date
    Apr 2009
    Location
    Pittsburgh, PA
    Posts
    17


    Did you find this post helpful? Yes | No

    Thumbs up

    I thought I posted a final reply - I got this working ok - the _ variables were in the symbol list. Sadly the bit variables are not there, which I find a bit strange.

    Thanks again for the help.

  10. #10
    Join Date
    Sep 2007
    Posts
    32


    Did you find this post helpful? Yes | No

    Default

    PBP BIT variables in MPLAB:

    Bit variables in PBP are created as aliases to individual bits within a byte variable created to hold them. MPLAB won't display the bit aliases, but it will display the byte container variable. The problem is, you don't know the name of the container variable or the placement of the specific bits without digging into the .ASM file.

    One solution is to create your own container variable and bit aliases. This won't make the bit names show in MPLAB, but it will allow you to show the container variable. You'll know which bits are which, because you defined their locations in the first place. There's no performance penalty using this method, because it's exactly what PBP would do if you declared bit variables. There are, in fact, advantages... like the ability to initialize multiple bit variables with a single command.

    <code>
    mybits VAR BYTE

    bitflag0 VAR mybits.0
    bitflag1 VAR mybits.1
    bitflag2 VAR mybits.2
    </code>

    Now the variable "_mybits" will be available in the MPLAB watch window, and you'll know how the individual bits in the variable relate to your program.
    Charles Leo
    microEngineering Labs, Inc.
    http://melabs.com

  11. #11
    Join Date
    Apr 2009
    Location
    Pittsburgh, PA
    Posts
    17


    Did you find this post helpful? Yes | No

    Thumbs up

    Excellent Charles! I fully intend to use this technique.

    Nice one.

    Quote Originally Posted by Charles_Leo View Post
    PBP BIT variables in MPLAB:

    Bit variables in PBP are created as aliases to individual bits within a byte variable created to hold them. MPLAB won't display the bit aliases, but it will display the byte container variable. The problem is, you don't know the name of the container variable or the placement of the specific bits without digging into the .ASM file.

    One solution is to create your own container variable and bit aliases. This won't make the bit names show in MPLAB, but it will allow you to show the container variable. You'll know which bits are which, because you defined their locations in the first place. There's no performance penalty using this method, because it's exactly what PBP would do if you declared bit variables. There are, in fact, advantages... like the ability to initialize multiple bit variables with a single command.

    <code>
    mybits VAR BYTE

    bitflag0 VAR mybits.0
    bitflag1 VAR mybits.1
    bitflag2 VAR mybits.2
    </code>

    Now the variable "_mybits" will be available in the MPLAB watch window, and you'll know how the individual bits in the variable relate to your program.

Similar Threads

  1. divide in pic basic pro
    By f6ggy in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th October 2003, 16:12
  2. pic basic pro for synthetiseur
    By f6ggy in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd October 2003, 21:01
  3. pic basic pro (novice user)
    By f6ggy in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd October 2003, 14:29
  4. help pic basic pro
    By f6ggy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 29th September 2003, 00:55
  5. How to use 93C46 Type EEPROM using PIC Basic PRo
    By in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 1st April 2003, 04:07

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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