Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
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.
12435 Discussions

Interval timer not counting up

Altera_Forum
Honored Contributor II
1,039 Views

I am new to the Nios II stuff, I have a design with the simple interval timer peripheral. It is not counting. Basically I expected to be able to read the counter value by reading the snapshot registers by using IORD_ALTERA_AVALON_TIMER_SNAPL & IORD_ALTERA_AVALON_TIMER_SNAPH. But I always get 0.  

 

I tried to start the counter from control register and also tried fidling with the options in Qsys for the timer. However, whatever I do in life, I still can't measure the counter counting up at all. 

 

Here is the code I tried last time: 

 

 

# include "sys/alt_stdio.h"# include "system.h"# include "altera_avalon_timer_regs.h"# include "alt_types.h"# include "stdio.h" int main() { alt_putstr("Hello from Nios II!\n"); alt_u16 x=0; IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER_0_BASE, 0xffff); IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER_0_BASE, 0xffff); /* Event loop never exits. */ while (1) { IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_0_BASE, 6); x=IORD_ALTERA_AVALON_TIMER_PERIODL(TIMER_0_BASE); printf("p: %u\n",x); x=IORD_ALTERA_AVALON_TIMER_PERIODH(TIMER_0_BASE); printf("p: %u\n\n",x); x=IORD_ALTERA_AVALON_TIMER_SNAPL(TIMER_0_BASE); printf("s: %u\n",x); x=IORD_ALTERA_AVALON_TIMER_SNAPH(TIMER_0_BASE); printf("s: %u\n",x); } return 0; }  

 

If possible could you compile a simple project with timer peripheral. I am feeling lost completely.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
146 Views

Yes I figured out what things were wrong and know how to do this stuff now, the most elusive problem was that I was calling IORD_ALTERA_AVALON_TIMER_SNAPL when I had infact changed to using 64 bit timer that needs IORD_ALTERA_AVALON_TIMER_SNAP_0 instead. However, the program compiled just fine but did not work as expected.

Reply