• AVR Freaks

AnsweredHot!Is there a way to view variables during runtime?

Page: 12 > Showing page 1 of 2
Author
chopnhack
Starting Member
  • Total Posts : 68
  • Reward points : 0
  • Joined: 2015/11/01 22:19:01
  • Location: 0
  • Status: offline
2016/03/06 20:10:37 (permalink)
0

Is there a way to view variables during runtime?

I want to watch the value of a variable while the pic is programmed and running, I assume there is no way to do this, but I ask to be sure. The pic in question is a 10LF320 and the programmer is a pickit3.
Thanks in advance.
#1
Bluedelta
Super Member
  • Total Posts : 302
  • Reward points : 0
  • Joined: 2015/10/18 16:50:03
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/06 20:51:39 (permalink) ☼ Best Answerby chopnhack 2016/03/06 21:12:11
+2 (2)
chopnhack
The pic in question is a 10LF320 and the programmer is a pickit3.



In-circuit debugging is quite possible. The PIC10LF320 however uses an additional debug header to do it.
 
However, it's also decently easy to use the simulator to test simple code.
#2
chopnhack
Starting Member
  • Total Posts : 68
  • Reward points : 0
  • Joined: 2015/11/01 22:19:01
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/06 21:11:21 (permalink)
0
I have used the simulator, but was interested in seeing what values TMR0 would start with while in circuit. I researched: but the chip wasnt listed, because the document is from 2006.
 
* I did find the debug header but at $50 - its out of my range, thanks for helping me narrow the search.
 
#3
Bluedelta
Super Member
  • Total Posts : 302
  • Reward points : 0
  • Joined: 2015/10/18 16:50:03
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/06 21:18:35 (permalink)
+1 (1)
chopnhack
I have used the simulator, but was interested in seeing what values TMR0 would start with while in circuit. I researched: but the chip wasnt listed, because the document is from 2006.
 
* I did find the debug header but at $50 - its out of my range, thanks for helping me narrow the search.



The datasheet should indicate what the reset value of each register is. In cases where this is ambiguous or you want to make double-sure, you can can initialize it to a value with MOVWF or CLRF.
 
As a note, if you're coding in ASM (which your other threads indicate), you'll perhaps be referring to 'registers' rather than 'variables'.
 
And yes, the debug header is somewhat pricey. The PIC10s are perhaps designed for low pin counts, where you have selected them in part specifically to eek out every bit of space. However, they are simple enough that such in-circuit debugging may tend not to be required.
#4
NKurzman
A Guy on the Net
  • Total Posts : 17610
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/06 21:52:33 (permalink)
0
I am not sure the pickit3 allows you to see variables during debugging. Assuming the header has that feature.
#5
Ian.M
Super Member
  • Total Posts : 13225
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 04:36:25 (permalink)
+1 (1)
All the ICD capable debug tools including PICkit 2 or 3 can view variables when the program is paused/stopped, if the silicon supports *ANY* debugging, but to view variables during execution requires a PIC24/dsPIC or PIC32 with DMCI support.  AFAIK no-one has back-ported the DMCI support code to any 8 bit PIC.

--
NEW USERS: Posting images, links and code - workaround for restrictions.
I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
#6
GeorgePauley
Moderator
  • Total Posts : 1143
  • Reward points : 0
  • Joined: 2009/12/01 13:59:30
  • Location: Chandler AZ
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 10:27:14 (permalink)
+2 (2)
First off, I want to try to make the following clear:
 
Microchip debuggers typically only allow examination of variables when the target device is halted.  (E.g. a breakpoint is hit.)  Debuggers do not allow examination of variables while the device is actually running.  In fact, examining variables while running is of questionable use since the target device is typically executing millions of instructions a second.  Some of the higher end debuggers do provide run-time-watch and trace, but only with higher end devices (e.g. Real-ICE and PIC32).  PIC10LF320 is not one of these devices.

"Ian.M"
AFAIK no-one has back-ported the DMCI support code to any 8 bit PIC

 
It's not a case of back-porting code.  These run-time features are actually built into the silicon.  A 10LF320 would no longer be a 10LF320 if it were modified to have these run-time features.  :)
 
"chopnhack"
I have used the simulator, but was interested in seeing what values TMR0 would start with while in circuit. I researched: but the chip wasnt listed, because the document is from 2006.


Actually simulator should be telling you exactly what the start up value is.  The simulator knows what the POR and MCLR reset values of all registers.
#7
Ian.M
Super Member
  • Total Posts : 13225
  • Reward points : 0
  • Joined: 2009/07/23 07:02:40
  • Location: UK
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 10:49:17 (permalink)
+1 (1)
GeorgePauley
"Ian.M"
AFAIK no-one has back-ported the DMCI support code to any 8 bit PIC

It's not a case of back-porting code.  These run-time features are actually built into the silicon.  A 10LF320 would no longer be a 10LF320 if it were modified to have these run-time features.  :)

IIRC DMCI also supports RTDM via the target PIC's UART.   Obviously this would be impossible/insane on a PIC10/12 but is there really any hardware limitation that makes it impossible e.g on a PIC18?

--
NEW USERS: Posting images, links and code - workaround for restrictions.
I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
#8
1and0
Access is Denied
  • Total Posts : 9495
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 11:05:34 (permalink)
+1 (1)
GeorgePauley
 
Actually simulator should be telling you exactly what the start up value is.  The simulator knows what the POR and MCLR reset values of all registers.

Even the ones with unknown values on POR, BOR, etc? mr green: mr green
#9
GeorgePauley
Moderator
  • Total Posts : 1143
  • Reward points : 0
  • Joined: 2009/12/01 13:59:30
  • Location: Chandler AZ
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 11:14:27 (permalink)
0
1and0
Even the ones with unknown values on POR, BOR, etc? mr green: mr green



I think so.  (But recognize the issue you raise.)  My "reasoning" is that I have yet to find registers with unknown POR values that aren't actually 0 every time I check with an actual device.  Of course I have not performed an exhaustive check of every SFR for every device.  The start of a simulator debug session will see all bits that don't have specific POR values set to 0.  (This is actually just a side effect of the underlying Java code.)  So I contend simulator matches registers on POR or debug session start.  For MCLR, BOR, etc. If the reset value of a bit is don't-care, or unknown, the simulator won't actually change those bits on those types of resets. 
 
But of course, the above argument is not hard-core proof.  sad: sad 
 
Getting back to the OP, TMR0 is a register we know the initial value of quite well.
#10
chopnhack
Starting Member
  • Total Posts : 68
  • Reward points : 0
  • Joined: 2015/11/01 22:19:01
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 12:55:27 (permalink)
+1 (1)
Thanks all!
 
So the simulator is very nearly identical to a real life evaluation of SFR due to knowing the reset values of the SFR's - understood. Since this is the case, I need to review my code for corrections.
 
GeorgePauley
So I contend simulator matches registers on POR or debug session start.  For MCLR, BOR, etc. If the reset value of a bit is don't-care, or unknown, the simulator won't actually change those bits on those types of resets. 
 
But of course, the above argument is not hard-core proof.  sad: sad 
 
Getting back to the OP, TMR0 is a register we know the initial value of quite well.


 
Yes, I found in the datasheet that the POR of TMR0 is all 'don't care' - but when simulated I always get a decimal value of 5 for the register.  TMR0 also doesn't change as the program moves through clock cycles as I expected it should. This is what led me to my initial questioning of whether the live vs. simulated should show differences.
#11
NKurzman
A Guy on the Net
  • Total Posts : 17610
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 13:23:18 (permalink)
+2 (2)
If the POR value is listed in the Data sheet as unknown, then you should set it it it matters to you.
It can change in the future
#12
Bluedelta
Super Member
  • Total Posts : 302
  • Reward points : 0
  • Joined: 2015/10/18 16:50:03
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 13:30:20 (permalink)
0 (2)
GeorgePauley
Microchip debuggers typically only allow examination of variables when the target device is halted.  (E.g. a breakpoint is hit.)  Debuggers do not allow examination of variables while the device is actually running.



I 'auto-translated' his term "running" to simply 'in the circuit and programmed', eheh.
 
GeorgePauley
My "reasoning" is that I have yet to find registers with unknown POR values that aren't actually 0 every time I check with an actual device.

 
Indeed. There is in fact no such thing as an 'unknown value' register, only one you should be circumspect about initializing. This is because the actual silicon designer knows what he or she is setting the value to per a set of causal paths from power on.
 
There can be multiple causal paths leading to a spread between possibilities for 1 or 0 at the time index you want, but the processor itself perhaps always 'knows' what the value is, and consequently the simulator will be programmed with those values or itself be in error.
#13
NKurzman
A Guy on the Net
  • Total Posts : 17610
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 13:33:54 (permalink)
+2 (2)
"Indeed. There is in fact no such thing as an 'unknown value' register, only one you should be circumspect about initializing. This is because the actual silicon designer knows what he or she is setting the value to per a set of causal paths from power on."
 
This assumes no race conditions that vary from lot to lot.
And No changes due to a change in the Silicon Revision.
 
Unknown means no Guarantee.
 
#14
1and0
Access is Denied
  • Total Posts : 9495
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 13:35:39 (permalink)
+1 (1)
The SIMulator has limitations, does not support all peripherals, and can be buggy too.  Best to test it on real hardware!
 
"Unknown" has too many variables.
 
<edit> Heck, even real hardware has its errata. ;)  I doubt the SIM will simulate that too.
post edited by 1and0 - 2016/03/07 13:39:37
#15
Bluedelta
Super Member
  • Total Posts : 302
  • Reward points : 0
  • Joined: 2015/10/18 16:50:03
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 13:38:15 (permalink)
+1 (1)
NKurzman
Unknown means no Guarantee.



Indeed. Like most datasheets, it indicates that Microchip has elected not to certify the state. It does not however mean the state has a 'massively' higher level of variance, or that you cannot be reasonably sure what it actually will be.
 
Very similar to varactor diodes: A stated varactor is merely certified to have a set capacitance. Other diodes however can and do exhibit a usable varactor effect.
#16
1and0
Access is Denied
  • Total Posts : 9495
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 13:55:11 (permalink)
+1 (1)
When all is said and done, work inside the specs stated in the datasheet; otherwise, it will be on your head. ;)
#17
NKurzman
A Guy on the Net
  • Total Posts : 17610
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 14:19:56 (permalink)
+4 (4)
Not on a Microchip CPU, But another Brand.
1) Read the entire data sheet section, in case there is a note that a Register default is undefined.  And it will affect the function in the beginning of the section that you only read up to the point you found the answer (worked for 4 years, then it did not).
2) After 10 years the default value in the RAM can change be one of the few numbers that will Crash your RTOS.
 
3)And your incorrect timing to an EEPROM may work for years because the parts were better than spec, until they were not.
 
Wrong works until it does not,  Ask BP.
#18
Bluedelta
Super Member
  • Total Posts : 302
  • Reward points : 0
  • Joined: 2015/10/18 16:50:03
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2016/03/07 14:24:10 (permalink)
+1 (1)
1and0
The SIMulator has limitations, does not support all peripherals, and can be buggy too.  Best to test it on real hardware!


This is of course true. Although note the humor that a simulator bug can affect even states the datasheet certifies to be a set value. The simulator must implicitly match the chip state for the currently available chip, or be declared 'in error' relative to its application goal.
 
No matter what revision or batch, the states are always 'known to the processor', and thus can be empirically isolated. You eventually get to the error probably surrounding 'any bug at all'.
 
Knowing how Microchip likes to do things though, they usually set 'unknowns' and 'unimplementeds' to zero, as Mr. Pauley indicates. The 'unknown' tag merely indicates that you should be circumspect about 'making sure, just in case', as Microchip has elected not to certify an 'expected confidence level'.
 
1and0
When all is said and done, work inside the specs stated in the datasheet; otherwise, it will be on your head. ;)

 
I will note that for more advanced engineering, one should consider a datasheet to be merely a 'guideline'. Understanding the first principles of operation is always more optimal.
 
You can get chips to do a lot of unexpected and helpful things, apart from the datasheet recommendations, by understanding how they operate.
#19
Heberley_1
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2018/03/18 11:02:13
  • Location: 0
  • Status: offline
Re: Is there a way to view variables during runtime? 2019/04/23 09:12:00 (permalink)
0
What do you mean with DMCI support? where can I find if a PIC18 does have DMCI support? thx
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2019 APG vNext Commercial Version 4.5