This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to view variables when stepping through .src files

Hello,

I have a variable of type Nat16 (unsigned int) which is called PulseWidth.

In the function that fills the variable PulseWidth, there's some assembler code (#pragma asm/endasm included in the .c file), so I have to indicate to the compiler to generate an assembler src file and to assemble this src file too.
Because of that, I have to open the corresponding .src file to put breakpoints (apparently, I can't put breakpoints in the 'normal' .c file).

When the breakpoint is hit, I would like to see the content of this variable in the watch window #1. However, I only see the value of one byte of this variable iso the whole variable. I have to open the memory window after looking where in the memory this variable is located, and only then I can see the two bytes (so, the 'complete' variable).

My question: how to show the complete variable when you have hit a breakpoint in a .src file? Is there something like PulseWidth and PulseWidth+1 to be defined in the watch window? The example I gave just now certainly does not work, because if you put PulseWidth+1, the watch window simply adds 1 to the value of PulseWidth. Is there some other way to represent the second byte (or better, the whole variable at once)?


Rgds,

--Geert

PS.: uVision version 2.33, C-compiler version 7.03.

Parents
  • The problem is that when you use the C compiler to generate an assembler SRC file, the obj file is generated by the assembler (not the C compiler). And, all the rules that apply to assembler files now apply to the object file.

    In assembler, there are no typed variables (like there are in C). In fact, there are no variables in assembler. There are only labels with either defined storage or with reserved storage (for 2 bytes in the case of an int).

    So, when you watch a "variable" in an object file that was created by the assembler, you are actually watching the label. And, the debugger has no idea how big that object is (since there is no type).

    The Keil debugger allows you to read a type from a starting address. This is done using the _R*** functions. For example, if your variable (err, label) is named xyz and it is an unsigned int, you can use the _rword function to display its value. For example:

    _rword(&xyz)

    returns the word value stored starting at the address of xyz.

    You may enter _rbyte in the command window or you may add it to the watch window. For example:

    ws 1, _rword(&xyz)

    Jon

Reply
  • The problem is that when you use the C compiler to generate an assembler SRC file, the obj file is generated by the assembler (not the C compiler). And, all the rules that apply to assembler files now apply to the object file.

    In assembler, there are no typed variables (like there are in C). In fact, there are no variables in assembler. There are only labels with either defined storage or with reserved storage (for 2 bytes in the case of an int).

    So, when you watch a "variable" in an object file that was created by the assembler, you are actually watching the label. And, the debugger has no idea how big that object is (since there is no type).

    The Keil debugger allows you to read a type from a starting address. This is done using the _R*** functions. For example, if your variable (err, label) is named xyz and it is an unsigned int, you can use the _rword function to display its value. For example:

    _rword(&xyz)

    returns the word value stored starting at the address of xyz.

    You may enter _rbyte in the command window or you may add it to the watch window. For example:

    ws 1, _rword(&xyz)

    Jon

Children