Intel® FPGA University Program
University Program Material, Education Boards, and Laboratory Exercises
1174 Discussions

NIOS II Interval Timer

Altera_Forum
Honored Contributor II
1,482 Views

Hi all, I have been struggling with NIOS II Interval Timer problem. I have done extensive search inside forum. I was able to find a few NIOS II Interval Timer posts + replies + working samples. 

 

I have tried those samples but entered following errors, 

 

1. I am using DE1 + NIOS II Core E + 20 kB RAM. 

I keep getting GLOBAL_POINTER out of range error 

during compilation. 

 

2. I am using Quartus II 9.1 NO Service Package 1 + 

NIOS II IDE 9.1 No Service Package 1. 

What are the settings in NIOS II project to 

enable Interval Timer? 

 

3. I have used -G0 option, but still getting 

GLOBAL_POINTER out of range error 

 

Any help is appreciated. 

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
562 Views

Are all your code sections in the same memory? Can you post your code section map? In the IDE, right-click on the BSP project, select Nios II > BSP Editor, and choose the Linker tab.  

 

Also in the BSP Editor, there's a button to show the memory map of all devices. It might be helpful to others to post that. (Sorry I'm not using the IDE right now so I'm not sure exactly where that button is). 

 

Peter
0 Kudos
Altera_Forum
Honored Contributor II
562 Views

Thank you for the prompt reply. I was able to figure out one of the problems. There was a problem with [.PTF] file. Every time I updated NIOSII properties, it did not refresh [.PTF] file. 

 

I created a new design and everything worked. But there was a second problem. Let me described my goal first. 

 

I would like to construct a program to flash LEDs on DE1 at one second interval. I would like to use the ALARM feature. I used NIOS II IDE 9.1, NOT NIOS II with ECLIPSE. 

 

Here is the [SYSTEM.H file], I only posted the INTERVAL_TIMER section. 

# define INTERVAL_TIMER_0_NAME "/dev/interval_timer_0"# define INTERVAL_TIMER_0_TYPE "altera_avalon_timer"# define INTERVAL_TIMER_0_BASE 0x00011000# define INTERVAL_TIMER_0_SPAN 32# define INTERVAL_TIMER_0_IRQ 0# define INTERVAL_TIMER_0_IRQ_INTERRUPT_CONTROLLER_ID 0# define INTERVAL_TIMER_0_ALWAYS_RUN 1# define INTERVAL_TIMER_0_FIXED_PERIOD 1# define INTERVAL_TIMER_0_SNAPSHOT 0# define INTERVAL_TIMER_0_PERIOD 10# define INTERVAL_TIMER_0_PERIOD_UNITS "ms"# define INTERVAL_TIMER_0_RESET_OUTPUT 0# define INTERVAL_TIMER_0_TIMEOUT_PULSE_OUTPUT 0# define INTERVAL_TIMER_0_LOAD_VALUE 499999# define INTERVAL_TIMER_0_COUNTER_SIZE 32# define INTERVAL_TIMER_0_MULT 0.0010# define INTERVAL_TIMER_0_TICKS_PER_SEC 100# define INTERVAL_TIMER_0_FREQ 50000000# define ALT_MODULE_CLASS_interval_timer_0 altera_avalon_timer 

 

 

Here is my complete program. It worked. If I pressed the RESET BUTTON on DE1, then it stopped working. 

# include <stdlib.h># include "stdio.h"# include "alt_types.h"# include "altera_avalon_pio_regs.h"# include "altera_avalon_timer.h"# include "altera_avalon_timer_regs.h"# include "system.h"# include "sys/alt_alarm.h" 

 

 

static alt_alarm alAlarmOne; 

static alt_u8 u8ContextOne = 0x01; 

static alt_u8 u8ContextTwo = 0x01; 

static alt_u8 u8LEDByte = 0x01; 

 

 

alt_u32 fxCallbackAlarmOne (alt_u8* u8ContextTwo) 

IOWR_ALTERA_AVALON_PIO_DATA (PIO_0_BASE, u8LEDByte); 

u8LEDByte = u8LEDByte << 1; 

 

 

if (u8LEDByte == 0) 

u8LEDByte = 0x01; 

}// 

 

 

return alt_ticks_per_second (); 

}// 

 

 

int main() 

if (alt_alarm_start (&alAlarmOne, 

alt_ticks_per_second (), 

fxCallbackAlarmOne, 

&u8ContextOne) < 0) 

printf ("No INTERVAL_TIMER defined\n"); 

 

return 1; 

}// 

else 

//printf ("INTERVAL_TIMER defined\n"); 

}// 

 

 

while (1) 

}// 

}// 

 

 

Can you identify the cause of programming stopped working after reset? Thanks alot. 

0 Kudos
Altera_Forum
Honored Contributor II
562 Views

Sorry I don't have DE1 kit so I probably can't help you much. I assume it runs code from non-volatile memory? If so, are you sure the bootloader is properly set up to copy to RAM upon reset? 

 

Peter
0 Kudos
Reply