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++

Interrupt Not Enable

Altera_Forum
Honored Contributor II
1,355 Views

Dear Friends, 

 

I am trying to use interrupt on Altera DE2_115 board. but it is not working. 

 

i am taking LOAD pulse as an interrupt and at every interrupt taking data from external bus "DATA[7..0]" , please have look on attached print-screen of my project 

 

load pulse comes at every 125 kbps 

 

Regards kaushal 

below is my code- 

#include <stdio.h>#include <string.h># include <ctype.h> /* RS232 Related Files....*/# include "alt_types.h"# include "altera_avalon_pio_regs.h"# include "sys/alt_irq.h"# include "system.h"# include <unistd.h> /* MicroC/OS-II definitions */# include "includes.h" /* Simple Socket Server definitions */# include "simple_socket_server.h" /* Nichestack definitions */# include "ipport.h"# include "tcpport.h" //---------------------------------------------------------------------------------# define HIGH 1# define LOW 0 # define PktSize 640# define PktCount 400 /* A variable to hold the value of the button pio edge capture register. */ volatile int edge_capture; static void handle_load_interrupts(void* context, alt_u32 id) { /* Cast context to edge_capture's type. It is important that this be * declared volatile to avoid unwanted compiler optimization. */ volatile int* edge_capture_ptr = (volatile int*) context; /* Store the value in the Button's edge capture register in *context. */ *edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(LOAD_BASE); /* Reset the Button's edge capture register. */ IOWR_ALTERA_AVALON_PIO_EDGE_CAP(LOAD_BASE, 0xF); /* * Read the PIO to delay ISR exit. This is done to prevent a spurious * interrupt in systems with high processor -> pio latency and fast * interrupts. */ IORD_ALTERA_AVALON_PIO_EDGE_CAP(LOAD_BASE); } void SSSSimpleSocketServerTask() { unsigned int LPktCount = 0; unsigned int Count = 0; //struct sockaddr_in servaddr,cliaddr; void* edge_capture_ptr = (void*) &edge_capture; /* Enable all 4 button interrupts. */ IOWR_ALTERA_AVALON_PIO_IRQ_MASK(LOAD_BASE, 0xf); /* Reset the edge capture register. */ IOWR_ALTERA_AVALON_PIO_EDGE_CAP(LOAD_BASE, 0x0); alt_ic_isr_register(LOAD_IRQ_INTERRUPT_CONTROLLER_ID, LOAD_IRQ,handle_load_interrupts, edge_capture_ptr, 0x0); fflush(stdin); fflush(stdout); printf("\n\t\t----Ready to Receive Interrupt----\n"); while(1) { do { if( edge_capture) //w.r.t. clock or LOAD Pulse from "sync_detect" { printf("\nHIGH"); IOWR_ALTERA_AVALON_PIO_DATA(TEMP_OUT_BASE,edge_capture); edge_capture = 0; printf("\nLOW"); IOWR_ALTERA_AVALON_PIO_DATA(TEMP_OUT_BASE,edge_capture); Count++; } if(Count == PktSize-1) { Count = 0; LPktCount++; } }while(LPktCount != (PktCount-1)); } }
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
311 Views

Did you enable the edge cap functionnality in the load PIO component? It is disabled by default. Be sure also to set the IRQ mode to 'edge'. 

To see if the problem is coming from the PIO (or something external) or the interrupt itself, you can try and replace "if( edge_capture)" by "if (IORD_ALTERA_AVALON_PIO_EDGE_CAP(LOAD_BASE))". If it works then, it means there is a problem with the interrupt process itself, if it doesn't, that's it a problem with the PIO or something connected to it.
0 Kudos
Altera_Forum
Honored Contributor II
311 Views

Hello Daixiwen, 

 

Thanking you for your reply, 

i have made a change as u mentioned (replacing edge_capture to IORD_ALTERA_AVALON_PIO_EDGE_CAP(LOAD_BASE))) but still it wont work. 

yes i enable the edge cap functionnality in the load PIO component and also set the IRQ mode to edge. 

i have add my .sopc file along with this post for better understanding of my problem. 

regards 

 

kaushal
0 Kudos
Altera_Forum
Honored Contributor II
311 Views

It looks like your PIO is configured correctly. I forgot something about the test. You should also disable the IRQ, for example by commenting the line with alt_ic_isr_register(). If the ISR is active, you risk have it read and clear the edge detection register before your main application can see it. 

If it still doesn't work, write another application that just reads the edge capture register and regularly prints it on the terminal. As long as this registers stays at 0 and doesn't see anything it's no use trying to get the interrupt to work. It means your problem is somewhere else. Are you sure you really have some rising edges on that PIO's inputs?
0 Kudos
Altera_Forum
Honored Contributor II
311 Views

125kHz is quite high for an interrupt, if your CPU is running at 100MHz that's only 800 cycles between two IRQs. My guess too is that the CPU is too slow to process it. From the regularity of the 'holes' in your last picture I'd say it is busy processing the system timer interrupt and that's why it doesn't process yours. 

If you need to process data coming at that speed I'd strongly advise to use some specialized hardware to do that, such as a DMA.
0 Kudos
Reply