|
|
View previous topic :: View next topic |
Author |
Message |
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
is it possible to keep track of the program counter ??? |
Posted: Wed Aug 24, 2005 11:10 pm |
|
|
Hi,
I want to send an ascii character to a PC via RS 232 port every time the program counter increments... is it possible to do this ???
thanks
arun |
|
|
Ttelmah Guest
|
|
Posted: Thu Aug 25, 2005 2:59 am |
|
|
No.
Think about it for a moment. The program conter increments every four cycles of the master clock. The fastest RS232 rate possibe, transfers one bit in the same time. It'd take an absolute minimum of ten instruction cycles to send one byte, and to send the program counter value, depending on the chip size, possibly three to four times this interval. Then you need the time to actually read the value and transfer it. With care you might be able to send a value every 100 instructions, but the processor is going to be doing nothing else...
Best Wishes |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Aug 25, 2005 6:29 am |
|
|
Why on earth would you want to do this? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Aug 25, 2005 6:46 am |
|
|
Something I sometimes do is put a putc() line at the start of major subroutines. Each subroutine prints a unique character and I can follow flow of the program by watching the characters. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Thu Aug 25, 2005 10:23 pm |
|
|
Hi,
That's exactly what I do.. everytime a character comes I know the PIC has executed the subroutine, but I thought I should extend the idea to each line instead of each subroutine....
thanks
arun |
|
|
Ttelmah Guest
|
Re: RE: |
Posted: Fri Aug 26, 2005 5:26 am |
|
|
arunb wrote: | Hi,
That's exactly what I do.. everytime a character comes I know the PIC has executed the subroutine, but I thought I should extend the idea to each line instead of each subroutine....
thanks
arun |
I think you are misunderstanding the relationship between the 'program counter', and C code. The code itself, no longer exists inside the processor. The whole 'point' of a compiler is it generates direct assembler, and then from this machine code. A single line of C could easily involve 1000 machine instructions (some complex printf statements). The relationship between the two is stored in the debugging file, which is how ICE/ICD/simulator systems allow you to see the progress through the 'C' code itself, rather than what the processor is actualy 'doing'. A system which output the program counter, would have to output a value for every single line in the internal code, and without the debugging information in front of you, would make little sense.
You can use serial outputs for debugging as already described, or the MPLAB simulator (which has access to the debugging file), or an ICE, with the same ability, or ICD, with breakpoints to display how you are progressing. A printout for every 'C' line, is relatively easy (generate a macro definition, which outputs a counter, and increments it - put as many as needed into your code, and to remove them at the end, just clear the definition), but one for each instruction, is a different order of magnitude!...
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|