Altera_Forum
Honored Contributor
13 years agounable to read data on Interrupt
I have ALtera DE2_115 Board having Cyclone IV E,
I am getting 8 bit data on 8-bit bus @ 125 kbps along with Clock. now i treat this clock (125kbps) as a interrupt and read 8-bit bus data on every clock. my Nios Processor misses some data while reading. input data :0,1,2,3,4,5,6,......................................255,0,1,2,3,4,5......255,0,1,2,3..............129 = 640 received data:0,1,2,--miss some data---251,252,253...255,0,1,2--again miss some data---255,---- = 640
static void *handle_load_interrupts(void* context, alt_u32 id)
{
edge_capture = 0;
volatile int* edge_capture_ptr = (volatile int*) context;
*edge_capture_ptr = IORD_ALTERA_AVALON_PIO_EDGE_CAP(LOAD_BASE);
//Store the value in the LOAD edge capture register in *context
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(LOAD_BASE,0); //Reset the LOAD edge capture register
IORD_ALTERA_AVALON_PIO_EDGE_CAP(LOAD_BASE); //Read the PIO to delay ISR exit. this is done to prevent a spurious
}
/* Enable all 4 button interrupts. */
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(LOAD_BASE, 0x01);
/* 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);
---------------------------------------------------------------------------
---this is the receiver code who read data from external bus "DATA"---
do
{
if( edge_capture) //w.r.t. clock or LOAD Pulse from "sync_detect"
{
ImgBuff = IORD_ALTERA_AVALON_PIO_DATA(DATA_BASE);
Count++;
edge_capture = 0; //reset generated LOAD interrupt
}
if(Count == 640-1) //check end of data -->640
{
Count = 0; //Point to Start of data
LPktCount++; //Increment Count
}
}while(LPktCount != (400-1));
Regards Kaushal