- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello I am trying to implement a timer triggered interrupt and I can not seem to get it to work and I don't really know what I am doing wrong.
Here is how it looks in Qsys where I have the interval timer component and it is connected to the IRQ. http://www.alteraforum.com/forum/attachment.php?attachmentid=12520&stc=1#include "system.h"
# include "sys/alt_stdio.h"
# include "sys/alt_irq.h"
# include "altera_avalon_pio_regs.h"
# include "altera_avalon_timer_regs.h"
const unsigned char sevenSegData = {0x40, 0x79, 0x24, 0x30, 0x19,
0x12, 0x02, 0x78,0x00, 0x10, 0x08,
0x03,0x46, 0x21, 0x06, 0x0E, 0x3F};
unsigned short switches;
unsigned char keys;
void timer_0_ISR(void *context)
{
// clear irq status in order to prevent retriggering
IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_0_BASE, 0);
alt_putstr("ISR TEST!\n");
}
int main()
{
// Timer initialization
IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_0_BASE, ALTERA_AVALON_TIMER_CONTROL_CONT_MSK
| ALTERA_AVALON_TIMER_CONTROL_ITO_MSK);
IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_0_BASE, 0); // Clear IRQ status just in case..
IOWR_ALTERA_AVALON_TIMER_PERIODL(TIMER_0_BASE, ALTERA_AVALON_TIMER_PERIODL_MSK);
IOWR_ALTERA_AVALON_TIMER_PERIODH(TIMER_0_BASE, ALTERA_AVALON_TIMER_PERIODH_MSK);
// Register the ISR for timer event
alt_ic_isr_register(TIMER_0_IRQ_INTERRUPT_CONTROLLER_ID, TIMER_0_IRQ, timer_0_ISR, 0, 0x0);
// Start timer
IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_0_BASE, 0x0007);
/* Event loop never exits. */
while (1)
{
switches = IORD_ALTERA_AVALON_PIO_DATA(SWITCH_BASE);
keys = IORD_ALTERA_AVALON_PIO_DATA(KEY_BASE);
IOWR_ALTERA_AVALON_PIO_DATA(LED_RED_BASE, switches);
IOWR_ALTERA_AVALON_PIO_DATA(HEX0_BASE, sevenSegData);
}
return 0;
}
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It actually works... I thought that the ALTERA_AVALON_TIMER_PERIODL_MSK & ALTERA_AVALON_TIMER_PERIODH_MSK would've been configured according to the Qsys setting but apparently they didn't so I had an 90 sec overflow and I didn't notice it until I actually went up and left my workstation and came back to see multiple messages from the ISR.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page