Altera_Forum
Honored Contributor
19 years agoHELP,I can't generate Hardware interrupt
I need help,please
What I want is : When I press a button ON Board, Nios Let LEDs lights.Of course,the LEDs is turned off before.(The board is DIY,Just a cyclone ep1c3t144c8 without flash and sdram.I download program to On_chip 4K ram for test. this is a test board,later I will make Nios with flash and sdram on PCB.SO,thanks for advice!!) the Problem is,Software is make just like nios example: nios\examples\software\count_binary software: static void handle_button_interrupts(void* context, alt_u32 id) { IOWR_ALTERA_AVALON_PIO_EDGE_CAP(0x1820, 0); //0x1820 is the addbase, input of my button for interrupts //problem is not getin here,I put breakpoint here,but never stop! IOWR_ALTERA_AVALON_PIO_DATA(0x1830,0xf);//Let leds light! // 0x1830 is the addbase of leds } int alt_main (void) { alt_u8 led = 0x00; alt_u16 i=0x0; alt_u16 j=0x0; alt_u8 inbit; IOWR_ALTERA_AVALON_PIO_IRQ_MASK(0x1820, 0xf); IOWR_ALTERA_AVALON_PIO_EDGE_CAP(0x1820, 0x0); j=alt_irq_register( 0, 0, handle_button_interrupts ); //The first para is 0:the IRQ on SOPC,I set it as 0 //the 2nd para is 0: the number to interrupt ,I set it 0 //the 3rd para is handle_button_interrupts:my interrupt gate! //I set breakpoint here,after this instruction ,j gets 0.it indicate that registe success! ...... the NIos developer's handbook says: Button is pressed, generating an IRQ. But when I press the button,Irq didn't generate!! The step I make SOPC: In SOPC,When I set key_in_pio,(IP is PIO), 1.In the first Dialog window,Width set "1"bits.and choose"Input ports only." 2.In the 2nd Dialog window,I just let it Generate IRQ, I choose "Level".then Pressed finish. Then in the main window,I set pio's IRQ as"0"; other IP:cpu,led pio,key_in_pio,onchip memory_0; Out of the FPGA,I let a Key to triger .When I press button,the level is 3.3v;otherwise the level is 0v; Thanks for spending time on reading this.