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.