- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page