FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
5887 Discussions

Interval Timer IP doesn't work

Gyud0
Beginner
608 Views

Hey,

I would like to use Interval Timer IP in order to measure execute time of a command by NIOS2 processor. My system frequency is 50MHZ.

 

I configured it by the properties:

1) Timeout period - 100ms.

2)Counter size:32.

3)Registers- Readable snapshot.

 

My whole ststem consist- NIOS2 processor,Interval Timer,JTAG UART and System ID.

the addresses range for the Interval Timer is 0x401000 up to 0x20103f.

 

In Eclipse, In Hal properties I chose SYS_CLK_TIMER :None. Also when I chose the Interval Timer it not works.

 

Can you help me please?

 

 

 

my C code is:

 

#include<stdio.h>

#include "io.h"

#include "system.h"

#include "altera_avalon_timer_regs.h"

#include "altera_avalon_timer.h"

 

#define SYS_CLK_TIMER_BASE 50000000

 

int main()

{

int a=3;

int b=5;

int c;

int snapl,snaph;

IOWR_ALTERA_AVALON_TIMER_PRIODH(SYS_CLK_TIMER_BASE,0XFFFF); //initiate PERIODH register

IOWR_ALTERA_AVALON_TIMER_PRIODl(SYS_CLK_TIMER_BASE,0XFFFF);//initiate PERIODL register

IOWR_ALTERA_AVALON_TIMER_SNAPL(SYS_CLK_TIMER_BASE,0X1);// first writing to either snapl or snaph to request a coherent snapshot of the counter

IOWR_ALTERA_AVALON_TIMER_CONTROL(SYS_CLK_TIMER_BASE,0X4);//START THE COUNTER

c=a+b;//the command that need to measure

IOWR_ALTERA_AVALON_TIMER_CONTROL(SYS_CLK_TIMER_BASE,0X8);//STOP THE COUNTER

snapl=IORD_ALTERA_AVALON_TIMER_SNAPL(SYS_CLK_TIMER_BASE);

snaph=IORD_ALTERA_AVALON_TIMER_SNAPH(SYS_CLK_TIMER_BASE);

printf("snapl=%d\n",snapl);

printf("snaph=%d\n",snaph);

//printf("The time to execute is=\n", (snaph-(snapl<<16))/ (1/SYS_CLK_TIMER_BASE);

return 0;

 

}

 

The output of this code is:

 

snapl=1;

snaph=0;

 

 

 

 

 

 

 

 

 

 

0 Kudos
3 Replies
Ahmed_H_Intel1
Employee
133 Views
Hi, I will try the same design and replicate this issue. It should be working.
Ahmed_H_Intel1
Employee
133 Views
Hi, BTW there are two modes ( system clock timer, and timestamp timer) once you set the timer as one mode you cannot use the other. Please check this. I am creating an example for you.
Ahmed_H_Intel1
Employee
133 Views

Hi Gyud0,

Attached is an example I've created to use the Interval timer IP on DE0-Nano_soc board. The example is working fine, please review it and replicate it on the board you have.

Regards,

 

Reply