Keil Logo

µVISION DEBUGGER: HOW CAN I LOG VARIABLE VALUES TO A FILE


Information in this article applies to:

  • µVision Version 2 and Later

QUESTION

I run my microcontroller application in the µVision simulator andon the target debugger. This application fills an array with data. Is it possible to write the values of this array to a file on my PC? Every time I modify my application, I want to compare the data with the previous version.

ANSWER

Yes, this is possible. Let's assume that the application defines an array like this:

unsigned char testarray[100];

Depending on the format you need, there are many ways to log these values to a file:

  • Use the µVision save command to save the data in a hex file:
    save MyValues.hex &testarray[0], &testarray[99]
    

    The file MyValues.hex then contains the values and the address information. Although viewing the values in this file may not be easy, this hex file may be loaded back into µVision to restore the values.

  • You can display the values in the command window and log them to a file:
    log > MyValues.log
    d &testarray[0], &testarray[99]
    0x00C240: 00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F ................
    0x00C250: 10 11 12 13 14 15 16 17 - 18 19 1A 1B 1C 1D 1E 1F ................
    0x00C260: 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F  !"#$%&'()*+,-./
    0x00C270: 30 31 32 33 34 35 36 37 - 38 39 3A 3B 3C 3D 3E 3F 0123456789:;<=>?
    0x00C280: 40 41 42 43 44 45 46 47 - 48 49 4A 4B 4C 4D 4E 4F @ABCDEFGHIJKLMNO
    0x00C290: 50 51 52 53 54 55 56 57 - 58 59 5A 5B 5C 5D 5E 5F PQRSTUVWXYZ[\]^_
    0x00C2A0: 60 61 62 63                                       'abc
    log off
    
    You will see the same text output in the file that was specified with the µVision LOG command (MyValues.log in this example).
  • You can log the values in any other format to a file by using user defined functions in the simulator or target debugger. The function can be invoked from the µVision command line or from a button in the toolbox.

    Define a user defined function in the µVision function editor.

    FUNC void displayvalues(void) {
      int idx;
    
      exec("log > MyValues.log");
      for (idx = 0; idx < 100; idx++) {
        printf ("testarray[idx] = %02X\n", idx, testarray[idx]);
      }
      exec("log off");
    }
    

    When the simulator is stopped, the function can be invoked in the µVision command line

    displayvalues()   // function invocation
    
    or you can define a button in the toolbox to start the function
    define button "Log Array", "displayvalues()"
    

    The values can be viewed in the command window and they are logged to the specified file:

    testarray[idx] = 00
    testarray[idx] = 01
    testarray[idx] = 02
    testarray[idx] = 03
    testarray[idx] = 04
    testarray[idx] = 05
    testarray[idx] = 06
    testarray[idx] = 07
    testarray[idx] = 08
    testarray[idx] = 09
    :
    testarray[idx] = 60
    testarray[idx] = 61
    testarray[idx] = 62
    testarray[idx] = 63
    

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Friday, February 24, 2017


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.