Simulation question

rq3

Senior Member
I haven't used the simulator much. Is there a way to make a RAM value "stick" at an assigned value during simulation, so that it ignores the code?

Thanks,
Rip
 

lbenson

Senior Member
If your code is assigning an undesired value at a certain point, can you not, for debugging purposes, immediately reassign the desired value? Or, before other code which tests or uses the value, change it to what you want.

I use the simulator a lot, and forcing the values in test code seems to be a significant part of the process.
 

rq3

Senior Member
If your code is assigning an undesired value at a certain point, can you not, for debugging purposes, immediately reassign the desired value? Or, before other code which tests or uses the value, change it to what you want.

I use the simulator a lot, and forcing the values in test code seems to be a significant part of the process.
I've been doing exactly what you suggest, but was hoping there was a more "elegant" way. I may be mis-remembering
that PE5 was capable of "over-riding" the code during simulation.
 

hippy

Technical Support
Staff member
There is no way to do that and I am sure PE5 never had it either.

Two possible solutions would be to comment out code which sets the variable, or add a line to force the variable to be set to a specific value before the part of the code you are seeking to test.
 

rq3

Senior Member
There is no way to do that and I am sure PE5 never had it either.

Two possible solutions would be to comment out code which sets the variable, or add a line to force the variable to be set to a specific value before the part of the code you are seeking to test.
Ah Ha! If I right click on an input pin on the simulator chip outline, I can assign a "sticky" value for a measured byte. It does indeed over-ride the default code value. For example, in the case of a simulated DS18B20 temperature measurement, the simulator defaults to 128 (zero centigrade), but right clicking the appropriate pin allows assigning any arbitrary positive " default temperature".
 

hippy

Technical Support
Staff member
What you are doing there is specifying what the value read will be when an 'input' or 'read' command is executed for that pin. It won't override the value in the variable elsewhere, but it will set it to the pin value specified whenever the input read is executed.

I hadn't worked out what you needed but glad you found it.
 

rq3

Senior Member
What you are doing there is specifying what the value read will be when an 'input' or 'read' command is executed for that pin. It won't override the value in the variable elsewhere, but it will set it to the pin value specified whenever the input read is executed.

I hadn't worked out what you needed but glad you found it.
Probably because I didn't explain it very well. It may also be a unique over-ride for hard coded variables for the "readtemp" command? In any case, it lets me set the temperature on the fly in the simulator, so may be of value to others.

Many thanks, Hippy et al!
 

Technical

Technical Support
Staff member
simply add an extra line such as this after readtemp

#ifdef simulating
variable = value
#endif

This will force the value during simulation, but the line will be ignored when actually downloaded.
 
Top