• AVR Freaks

Hot!Is it possible to trace values in Data memory?

Author
leadinglights
Super Member
  • Total Posts : 392
  • Reward points : 0
  • Joined: 2003/11/07 12:41:48
  • Status: offline
2019/04/12 08:53:17 (permalink)
0

Is it possible to trace values in Data memory?

Is there any way to trace values in data memory in Simulator to verify that an algorithm is working correctly.

I am injecting values into ADRESL using Stimulus and each new value changes three 16 bit variables (sum of last 40 new values, sum of last 8 new values and the slope of the last 9 values) which are in the shared part of data memory. At the moment I am recording these by hand from a watch window and this is  a pain in the posterior laborious and error prone.

I seem to recall having seen almost exactly this done on MPLAB in the past but can't find any info on the procedure.

Mike
#1

16 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 17485
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/12 14:30:21 (permalink)
    0
    I think you can send it to the serial Port.  And that has a window.
     
    Are you using MPLab8 or MPLab X?
    #2
    leadinglights
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Joined: 2003/11/07 12:41:48
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/12 15:20:38 (permalink)
    0
    Thanks NKurzman, I will try that.
     
    I use MPLab X and have been trying to wean myself off of using MPLab 8 every time I have a problem  as it is falling behind on processors and tools that it supports - It would be a little like calling somebody out of a well earned retirement simply because nobody else can do the job.
     
    Mike
    #3
    Jim Nickerson
    User 452
    • Total Posts : 6016
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/13 08:30:37 (permalink)
    0
    Maybe the "DMCI" plugin would be of use
    #4
    leadinglights
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Joined: 2003/11/07 12:41:48
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/14 11:26:57 (permalink)
    +1 (1)
    In the end I weakened and used MPLab 8 which did a perfect job of register injection from a file and traced 3  different 16 bit variables to three seperate files.  It also did this in an intuitive and straightforward way.
     
    I will try to get to grips with SCL as I know that using MPLab 8 will keep me from getting on in the world - but going cold turkey is very hard.
     
    Edit:
        I used "Generate SCL" and got a comprehensible SCL file that I could immediately understand. Tip to all those who, like me, hide under the table when faced with SCL: Use MPLab initailly to do your register inject/ register trace. Use the advanced option to generate an SCL file and look at that - all will make sense , the sun will break through the clouds etc..
        O.K., the byte order of the trace file is the wrong way round but that is what spreadsheets are for.
     
    Mike
     
     
    post edited by leadinglights - 2019/04/14 12:02:02
    #5
    leadinglights
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Joined: 2003/11/07 12:41:48
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/17 05:16:47 (permalink)
    0
    At this point I can do everything I now want to in MPLab 8 but am hoping to move this project from a PIC12F1840 to a more recent PIC (PIC16F18313 at the moment) and form PicKit 3 to PicKit 4 so I want to be able to  inject values into registers and trace multiple variables.  I tried using the .SCL file generated in MPLab 8 in MPLab X, expecting errors which I could hopefull resolve. The error generated was:-

    Error: E0103-SIM: Failed to parse SCL E9816-SCL: Invalid parameter line(27)

    I have not been able to find any of the code examples in the SCL repository, nor is the SCL PRIMER / TUTORIAL or even the thread Coding directly in SCL\SCL asd VHDL subset. In every case there is a 404 error. In addition, I have not even been able to find if this is possible in MPLab X, but tantilising clues that it is - balanced by an equal number of clues that it is not possible. Only the documentation in the MPLab X installation directory has any info and that seems sketchy.
     
    In the hopes that somebody can give a non-negative answer I have attached the code below.
     
    // 
    // C:\Projects\Software\MPLAB8\StimTry2.scl
    // Generated by Stimulus ver. 3.60.00.00
    // 4/14/2019 19:41:40
    //


    configuration for "pic12f1840" is
        shared label WayPoint;
        shared variable Slope;
        shared variable Tot_40;
        shared variable Tot_8;
    end configuration;


    testbench for "pic12f1840" is
    begin
        process is
        begin
            wait;
        end process;

        // Register Injection
        Get: process is
        begin
            accessin("C:\Projects\Software\PiezoSW\Morph.X\Stimulus files\ADCStimX16.txt", hex_mode, ADRESL, true);
            wait;
        end process Get;

        // Register Trace
        SL1: process is
        begin
            triggerout_gpr("Slope.txt", binary_mode, Slope, WayPoint, 2);
            wait;
        end process SL1;

        // Register Trace
        T8: process is
        begin
            triggerout_gpr("Tot8.txt", binary_mode, Tot_8, WayPoint, 2);
            wait;
        end process T8;

        // Register Trace
        T40: process is
        begin
            triggerout_gpr("Tot40.txt", binary_mode, Tot_40, WayPoint, 2);
            wait;
        end process T40;

    end testbench;


     
    Thanks for any enlightenment you can bring.
     
    Mikeyou can 
    #6
    GeorgePauley
    Moderator
    • Total Posts : 1119
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/17 09:41:07 (permalink)
    0
    Line 27 (actually 26) is the accessin call.  It works fine for me, when I put a valid filename in place of the one you use.  Which makes me suspect that you perhaps aren't a valid filename for your system?
     
    I can tell you that the triggerout stuff isn't going to work (though it still compiles).  We removed these functions in MPLAB X.  We felt that the purpose of SCL was to inject values into the simulator.  Having debug functions like triggerout that extracted values from the simulator really muddied the waters of the already overly complex SCL code. 
     
    To trace registers, use the register trace feature of the simulator.  Main menu -> Window -> Simulator -> Register Trace.
    #7
    leadinglights
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Joined: 2003/11/07 12:41:48
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/17 10:56:52 (permalink)
    0
    Thanks for your help George but the time I have already spent on trying to get Register Trace to work on variables in the data memory in asseembly language programs means that, at least until the world changes, all of my stimulus and tracing will be done in MPLab 8.
     
    I will continue enjoy using MPLab X for other things - and will almost certainly be back asking for help on those things.
     
    Mike
     
     
    #8
    leadinglights
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Joined: 2003/11/07 12:41:48
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/22 11:11:17 (permalink)
    0
    Although MPLab 8.92 was working well, I have already been asked to use a more recent MCU in the present project so must try to get Register Trace working in MPLab X and logging to a file. The present situation is:-
     

    MPLab X 5.15
    MPASM
    PIC12F1840 (at the moment)
     
    The variables I wish to trace are reserved and declared as global but no variables are presented in the Register Trace.
     

     

    Vars       UDATA_SHR

               ; Omitted for brevity

    Tot_40     RES 2     ; Total for running average

    Tot_8      RES 2     ; Total for limit trigger

    Slope      RES 2     ; S/G slope

       

               GLOBAL    Slope, Tot_8, Tot_40

     


       
     
    I entered Debug mode then paused the run  and selected Window - Simulator - Register Trace. Then I clicked in the area marked "Click here to add/remove trace variables". From Available Registers I selected Globals Only but no variables were available for selection.
     
     
    I have also looked at File - Project Properties - Simulator - Option category "Trace" - Data Collection Section but the only options are "Off" and "Instruction Trace".
     
    I further explored the Simulator options by following a note in the Trace category
     
     
    User Instrumented Trace
    Through the use of TRACE and LOG macros in user code, variable information may be reported to the IDE .....

     
    However I was unable to find any options for this nor do either the MPASM Users Guide (DS33014L) or MPLab X Users Guide (DS50002027D) give any clues.
     
    I have been successfully using Register Trace along with Register Injection on MPLab 8.92 but now need to look at using more recent MCUs
     
     
    Thanks for any help you can give,
    #9
    GeorgePauley
    Moderator
    • Total Posts : 1119
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/23 08:44:35 (permalink)
    0
    Globals likely requires a project build so that we have an elf file to extract global names and addresses from.  You should see the list of SFRs in the SFRs Only section.
    #10
    leadinglights
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Joined: 2003/11/07 12:41:48
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/23 10:06:46 (permalink)
    0
    How do you build a MPASM project to produce an ELF file?
     
    I have looked through the MPASM MPLINK users guide and the MPLab X users guide and on the forum, in the Microchip Developers help  and am none the wiser. I think I understand the concept, but can't find how to change from COFF to ELF format.
     
    Thanks,
     
    Mike
    #11
    GeorgePauley
    Moderator
    • Total Posts : 1119
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/23 15:25:11 (permalink)
    0
    COFF is fine too.  I just said ELF because its the most common format. 
     
    The point is global variables will not be available drop down list until the internal MPLAB X component (translator) that reads the debug information out of the debug image file (COFF, ELF, DWF, etc), has that file available to read and decode.  And that can't happen until a build has occurred.
    #12
    leadinglights
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Joined: 2003/11/07 12:41:48
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/24 02:49:56 (permalink)
    0
    On building for debug by clicking on Debug - Debug main project, the output shows that it is producing a COFF file. (output attached below) Looking at the file Piezo14.X.debug.cof, although it is not a text file all of the variables are visable as ASCII but the globals are not shown differently from those not declared as global.

    As far as I can tell I have correctly declared my global variables with the global directive after the variable lable is defined.

    Is it possible that the linker optimises out the global directive as there is/are no other files calling those as external? I tried adding on an extra file called "Dummy" which called my global variables as external but still no global variables appeared in the Register Trace window.
     
    Edit: Is it possible that the file path is too long? I know earlier MPLab versions did have problems with this and the full path would be C:\Projects\Software\PiezoSW\Piezo14.X\dist\default\debug\Piezo14.X.debug.cof

    Mike
     

    make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory 'C:/Projects/Software/PiezoSW/Piezo14.X'
    make -f nbproject/Makefile-default.mk dist/default/debug/Piezo14.X.debug.cof
    make[2]: Entering directory 'C:/Projects/Software/PiezoSW/Piezo14.X'
    "C:\Program Files (x86)\Microchip\MPLABX\v5.15\mpasmx\mpasmx.exe" -d__DEBUG -d__MPLAB_DEBUGGER_SIMULATOR=1 -q -p16f1703 -l"build/default/debug/Piezo14.lst" -e"build/default/debug/Piezo14.err" -o"build/default/debug/Piezo14.o" "Piezo14.asm"
    "C:\Program Files (x86)\Microchip\MPLABX\v5.15\mpasmx\mplink.exe" -p16f1703 -w -x -u_DEBUG -z__ICD2RAM=1 -m"dist/default/debug/Piezo14.X.debug.map" -z__MPLAB_BUILD=1 -z__MPLAB_DEBUG=1 -z__MPLAB_DEBUGGER_SIMULATOR=1 -odist/default/debug/Piezo14.X.debug.cof build/default/debug/Piezo14.o
    MPLINK 5.09, LINKER
    Device Database Version 1.46
    Copyright (c) 1998-2011 Microchip Technology Inc.
    Errors : 0

    make[2]: Leaving directory 'C:/Projects/Software/PiezoSW/Piezo14.X'
    make[1]: Leaving directory 'C:/Projects/Software/PiezoSW/Piezo14.X'

    BUILD SUCCESSFUL (total time: 2s)
    Loading symbols from C:/Projects/Software/PiezoSW/Piezo14.X/dist/default/debug/Piezo14.X.debug.cof...
    Loading code from C:/Projects/Software/PiezoSW/Piezo14.X/dist/default/debug/Piezo14.X.debug.cof...
    Loading completed


    post edited by leadinglights - 2019/04/24 07:02:43
    #13
    GeorgePauley
    Moderator
    • Total Posts : 1119
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/24 08:27:10 (permalink)
    0
    To be honest, I don't know.  From the simulator's point of view the Translator (MPLAB X COFF file reader internal component) tells us what global variables are available.  How Translator extracts that info from the COFF file, or how the assembler decides what goes in the COFF file in the first place is not my area of expertise.  Maybe asking this question over in the assembler forum?

    To double check:  Are you at least seeing the SFRs?  Or is this a more general problem with the register trace GUI?
    #14
    leadinglights
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Joined: 2003/11/07 12:41:48
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/24 10:19:19 (permalink)
    0
    All SFRs are visible but when the selection is globals then the pane is empty.
     
    Mike
    #15
    GeorgePauley
    Moderator
    • Total Posts : 1119
    • Reward points : 0
    • Joined: 2009/12/01 13:59:30
    • Location: Chandler AZ
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/25 08:50:01 (permalink)
    0
    Then it's definitely an issue of what constitutes an assembly language global variable that is visible to the register trace window.  Something I don't know too much about.  I would suggest asking the question in the MPLAB X and/or the assembler forum.
    #16
    leadinglights
    Super Member
    • Total Posts : 392
    • Reward points : 0
    • Joined: 2003/11/07 12:41:48
    • Status: offline
    Re: Is it possible to trace values in Data memory? 2019/04/27 02:56:54 (permalink)
    0
    I have asked on the assembler forum and followed up on their suggestions: variations on external files to use or define/decalre the globals or assigning the variables to physical addresses - I have even tried changing the project to an absolute mode (which never was going to work but I was that desparate)
     
    Nothing worked and I think on balance that Register Trace is broken in MPLab X v5.15 and probably others.
     
    For the moment I have a kludge that will suit my purpose: Performing the checks that need register injection on a PIC16F1704 in MPLab 8.92 then do the rest of the work - not needing Register Trace - on a PIC16F1703 in MPLab X.
     
    I am concerned though that by the next project - on an even newer MCU - this kludge will no longer be possible. If you have communications with those who are responsible for the Register Trace, could I ask you to request that they put it on their To Do List.
     
    Thanks,
     
    Mike
    #17
    Jump to:
    © 2019 APG vNext Commercial Version 4.5