CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

is it possible to keep track of the program counter ???

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

is it possible to keep track of the program counter ???
PostPosted: Wed Aug 24, 2005 11:10 pm     Reply with quote

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







PostPosted: Thu Aug 25, 2005 2:59 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Aug 25, 2005 6:29 am     Reply with quote

Why on earth would you want to do this?
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Aug 25, 2005 6:46 am     Reply with quote

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

View user's profile Send private message Send e-mail

RE:
PostPosted: Thu Aug 25, 2005 10:23 pm     Reply with quote

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:
PostPosted: Fri Aug 26, 2005 5:26 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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