Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12609 Discussions

nr_timer_milliseconds not found?

Altera_Forum
Honored Contributor II
984 Views

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.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
305 Views

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
0 Kudos
Altera_Forum
Honored Contributor II
305 Views

Hi Doug! 

 

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

 

Bye, Lothar.
0 Kudos
Altera_Forum
Honored Contributor II
305 Views

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
0 Kudos
Reply