[En-Nut-Discussion] Timing on AVR32

Thiago A. Corrêa thiago.correa at gmail.com
Thu May 17 03:50:05 CEST 2012

Hi Daniel,

On Wed, May 16, 2012 at 8:22 PM, Daniel Fiedler (Ethernut)
<ethernut at fitus.de> wrote:
> void NutRegisterTimer(void (*handler) (void *))
> {
>    /* Set compare value for the specified tick frequency. */
> //    Set_system_register(AVR32_COMPARE, NutGetCpuClock() / NUT_TICK_FREQ + Get_system_register(AVR32_COUNT));
>        Set_system_register(AVR32_COMPARE, NutGetCpuClock() / NUT_TICK_FREQ );
>    sig_sysCompare.ir_handler = handler;
>    register_interrupt(SystemCompareIrqEntry, AVR32_CORE_COMPARE_IRQ, AVR32_INTC_INT0);
> }
> I changed line 4 in line 5. Now system seems to run at the correct speed.
> But Nut/os needs about 15-20s for boot/init.
> Could someone explain this function?

If memory serves well, NutGetCpuClock() / NUT_TICK_FREQ was supposed
to be the clock cycles in 1ms. The COUNT register increments
regardless of pipeline stalls. So, after the equivalent of 1ms cycles,
the COMPARE IRQ would fire calling the handler callback.

This is explained in section 2.6 of the "Technical Reference Manual".

What do you mean it takes 20s to boot? To start firing your timer or
to actually reach main() first line? (Actually NutMain since main is a
preprocessor macro in NutOS)

Kind Regards,
    Thiago A. Correa

More information about the En-Nut-Discussion mailing list