Forum Discussion
Altera_Forum
Honored Contributor
12 years agoReading external data using On-chip FIFO and NIOS II
Hi all, I'm trying to read a 8-bit ADC with parallel output using NIOS II. I need to read the ADC at 24MHz to capture correct samples. I have been trying a 1K On-Chip FIFO to capture this data....
Altera_Forum
Honored Contributor
12 years agoI have configured the FIFO this way:
int init_input_fifo()
{
int code = ALTERA_AVALON_FIFO_OK;
code = altera_avalon_fifo_init(0x2001800, // Address
0x3F, // Enable interrupts
1, // Almost empty
1000); // Almost full
if (code == ALTERA_AVALON_FIFO_EVENT_CLEAR_ERROR)
printf("A\n");
else if (code == ALTERA_AVALON_FIFO_IENABLE_WRITE_ERROR)
printf("B\n");
else if (code == ALTERA_AVALON_FIFO_THRESHOLD_WRITE_ERROR)
printf("C\n");
//printf("CODE: %d\n", code);
printf("ALMOSTEMPTY = %d\n", altera_avalon_fifo_read_almostempty(0x2001800));
printf("ALMOSTFULL = %d\n", altera_avalon_fifo_read_almostfull(0x2001800));
void* input_fifo_wrclk_irq_event_ptr = (void*) &input_fifo_wrclk_irq_event;
alt_irq_register(16, input_fifo_wrclk_irq_event_ptr, handle_input_fifo_wrclk_interrupts);
return code;
} The ALMOSTEMPTY and ALMOSTFULL printed in the console are correct. My interrupt: static void handle_input_fifo_wrclk_interrupts(void* context, alt_u32 id)
{
volatile int* input_fifo_wrclk_irq_event_ptr = (volatile int*) context;
*input_fifo_wrclk_irq_event_ptr = altera_avalon_fifo_read_event(0x2001800, ALTERA_AVALON_FIFO_EVENT_ALL);
altera_avalon_fifo_clear_event(0x2001800, ALTERA_AVALON_FIFO_EVENT_ALL);
printf("INTERRUPT!!!");
} Thanks