Altera_Forum
Honored Contributor
13 years agoInterrupt Not Enable
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));
}
}