Re: simavr from a gui -- cycle timers

41 views
Skip to first unread message

M P

unread,
Sep 2, 2010, 7:04:18 AM9/2/10
to sim...@googlegroups.com
On Thu, Sep 2, 2010 at 10:43 AM, arcachofo <sant...@gmail.com> wrote:
>
> Another cuestion i have to solve is the number of clock cycles per
> instruction... is there any way my app can know this?
>

Actually I was thinking you might want to look at :

avr_cycle_timer_register() in sim_cycle_timers.h -- it allows you to
register a function that will be called (as close as) after a number
of cycles you specify. With a judicious use of setjmp()/longjmp() you
could possibly "interrupt" the simavr core every few cycles to do your
own stuff, and let it resume when you want...

Just an idea, maybe it's worth checking it out...

Michael

arcachofo

unread,
Sep 2, 2010, 8:19:11 AM9/2/10
to simavr


On 2 sep, 12:04, M P <buser...@gmail.com> wrote:
Well... not understand very well, i have to learn more about how
simavr works.

But i don't understand how this can help in the problem i talked
about:

I actually have a for loop that calls avr_run(avr) once per loop step,
this loop is executed by a timer event; the timer period and the
number of for loop steps are calculated to call avr_run(avr) certain
number of times per second.

Then as you commented in other post i spect simavr to run 1
instruction in every step on my loop.

But... what about instructions that take several clock cycles?
For example if i call avr_run(avr) and it executes a CALL instruction
it should take 4 clock cycles (i think), but as i undertand it, simavr
will do it in just 1 cycle; then my app should know it and do nothing
in the 3 next loop steps...

The problem is that instruction-cycles != clock-cycles, indeed:
instruction-cycles < clock-cycles, and my app wants to execute 1 mcu
clock cycle every loop step.

I think i just have to learn more about how simavr works and then try
to solve these issues.

M P

unread,
Sep 2, 2010, 8:33:30 AM9/2/10
to sim...@googlegroups.com
avr_run() runs one instruction. It can't splice it down lower than
that. so yes it can be from one avr clock cycle to 4 or so...

to know how many cycles it ran, do :
avr_cycle_count_t old = avr->cycle();
avr_run(avr);

avr_cycle_count_t delta = avr->cycle - old;

Michael

arcachofo

unread,
Sep 2, 2010, 9:13:14 AM9/2/10
to simavr


On 2 sep, 13:33, M P <buser...@gmail.com> wrote:
> avr_run() runs one instruction. It can't splice it down lower than
> that. so yes it can be from one avr clock cycle to 4 or so...
>
> to know how many cycles it ran, do :
> avr_cycle_count_t old = avr->cycle();
> avr_run(avr);
>
> avr_cycle_count_t delta = avr->cycle - old;
>

Ok, then forget what i say in the other post, now i know how to do it.
Reply all
Reply to author
Forward
0 new messages