Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12612 Discussions

the problem of the PIO interrupts

Altera_Forum
Honored Contributor II
1,168 Views

Hello,everybody! 

 

My program can't get into the interrupt fuction. the code like is the following.is there any questions? and I can't use a main() but alt_main(),if I use main() the nisoII IDE show me many errors;I use a CPU /e. 

 

CODE: 

 

# include "system.h"# include "altera_avalon_pio_regs.h"# include "alt_types.h"# include "sys/alt_irq.h" 

volatile int edge_capture; 

 

void Sirq(void * context,alt_u32 id) 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_SWITCH_BASE, 0); 

IOWR_ALTERA_AVALON_PIO_DATA(PIO_LED1_BASE,IORD_ALTERA_AVALON_PIO_DATA(PIO_SWITCH 

_BASE)); 

int main (void) __attribute__ ((weak, alias ("alt_main"))); 

int alt_main (void) 

alt_irq_register(PIO_SWITCH_IRQ,(void *)0,Sirq); 

IOWR_ALTERA_AVALON_PIO_EDGE_CAP(PIO_SWITCH_BASE, 0); 

IOWR_ALTERA_AVALON_PIO_DIRECTION(PIO_SWITCH_BASE, 0); 

IOWR_ALTERA_AVALON_PIO_IRQ_MASK(PIO_SWITCH_BASE, 0xff);  

 

while (1)  

 

return 0; 

 

 

Thanks~!
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
262 Views
0 Kudos
Altera_Forum
Honored Contributor II
262 Views

You can't use alt_main() _and_ the alt_irq_register() function. You've got to be using a program with main(). I know that you mentioned that you had troubles compiling code with main() in it, but you have to have it if you want to use the HAL functions. (like alt_irq_register()) 

 

By using alt_main() you're telling the tools that you don't want to use any of the HAL's functionality. 

 

The count_binary() example shows you how to do this. 

 

Best Regards, 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
262 Views

yeah~, the problem is solved! 

 

slacker,Thank you very much! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/tongue.gif
0 Kudos
Reply