Reply by Anders Lindgren●December 2, 20052005-12-02
pollyp100 wrote:
> Hi,
>
> I am writing some C-SPY macros which use __orderInterrupts. To
> schedule them properly I need to know how many ticks I am into the
> program (ignoring overflow for now). Is there a way to get this
> information programmatically, either in C or assembler, *without*
> setting up a timer?
>
> I'm using IAR's embedded workbench, and then I open the CPU
registers
> window during the debugging I see registers called CYCLECOUNTER,
> CCTIMER1, and CCTIMER2. They look like what I want. But when I try
> things like "mov.b CYCLECOUNTER,R12" I get an undefined symbol
error.
> Any ideas?
Those registers are only pseudo-registers, they have no physical
correspndence.
However, in the symulator you can refere to them from the macro language
like #CYCLECOUNTER.
What you can do is to define a global variable, say __cycles, and define
a break-point that triggers a macro that writes the current value of the
cyclecounter into that variable. For example:
... in some function ...
{
// This will break the simulator *before* the value is read.
__setSimBreak("__cycles", "R", "Access()");
}
Access()
{
// __message("Access() called\n");
__cycles = (long)#CYCLECOUNTER;
}
Again, this only works in the simulator, not if you run on real
hardware. On the other hand, on real hardware you hardly have to fake
interrupts.
-- Anders Lindgren, IAR Systems
--
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.
These are not hardware counters. The only way to do this in the
functional code is by running a timer, which is easy enough to do,
simply inintialise & enable the timer in continuous up counting mode and
enable the overflow interrupt (for tracking overflows if you want to)
then use:_
mov &TAR,R12
The mov.b CYCLECOUNTER,R12
is a byte move and would lose the MSB of the counter anyway.
Cheers
Al
pollyp100 wrote:
>Hi,
>
>I am writing some C-SPY macros which use __orderInterrupts. To
>schedule them properly I need to know how many ticks I am into the
>program (ignoring overflow for now). Is there a way to get this
>information programmatically, either in C or assembler, *without*
>setting up a timer?
>
>I'm using IAR's embedded workbench, and then I open the CPU
registers
>window during the debugging I see registers called CYCLECOUNTER,
>CCTIMER1, and CCTIMER2. They look like what I want. But when I try
>things like "mov.b CYCLECOUNTER,R12" I get an undefined symbol
error.
>Any ideas?
>
>Thanks in advance,
>
>P.
>
>
>
>
>
>
>
>.
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
Reply by pollyp100●November 30, 20052005-11-30
Hi,
I am writing some C-SPY macros which use __orderInterrupts. To
schedule them properly I need to know how many ticks I am into the
program (ignoring overflow for now). Is there a way to get this
information programmatically, either in C or assembler, *without*
setting up a timer?
I'm using IAR's embedded workbench, and then I open the CPU registers
window during the debugging I see registers called CYCLECOUNTER,
CCTIMER1, and CCTIMER2. They look like what I want. But when I try
things like "mov.b CYCLECOUNTER,R12" I get an undefined symbol error.
Any ideas?
Thanks in advance,
P.