Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

nr_timer_milliseconds not found?

Hello Friends!

When I compile this piece of code

#include <asm/timer_struct.h>
int Timer_TimerDif(Timer_Data_t *timerData)
{
  return nr_timer_milliseconds()-timerData->iStartTimer;
}

I get this error message:

undefined reference to `nr_timer_milliseconds&#39;

Although timer_struct.h contains the following declaration of nr_timer_milliseconds

int nr_timer_milliseconds();  // Starts on first call, hogs timer1.

The definition of struct np_timer for variable timerData is found by the compiler in timer_struct.h. But nr_timer_milliseconds is not founded?

Bye, Lothar.

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Lothar,

    I haven&#39;t used this before, but I believe you need to create a timer in you Nios core and call it na_timer1. A note claims this will tie up the counter completely, so it is probably best anyway.

    The function is defined in timer_milliseconds.c

    If you did a standard installation, the path will be (from a nios terminal)

    cygdrive/c/altera/kits/nios2/components/altera_avalon_timer/sdk_c/lib/

    Doug
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi Doug!

    How can I create a new timer in a kernel project?

    Bye, Lothar.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Lothar,

    Since you should have a dedicated timer for this function, you should probably go back to SOPC builder and create one. You can not just create one for the kernel project, it has to be generated by SOPC builder first.

    However, for the purpose of checking it out, you may be able to use one that is already available. If you are using an Altera Dev board, I think most of them have something like a sys_timer and high_res_timer pre-defined. Try using the high_res_timer, although remember this is a us timer and not a ms timer.

    Create a na_timer1 in your code and assign it to the address of you high_res_timer, see how things go. Timers and addresses should be available in your system.h file, ptf file, or SOPC builder. Once you iron our the details go back to SOPC builder and create a timer devoted to support this function.

    Doug