Altera_Forum
Honored Contributor
10 years agoModular ADC - MAX10
Hello,
I`m currently trying to make the ADC of a MAX10 board work but I can`t seem to get my interruption correctly. I could configure the modular ADC to the sequence mode with NIOS correctly, but the interruption turned out to be a big hassle in my life. The code below is my int, which I try to initiate the interruption with the API "altera_modular_adc_init" and I try to set up the API "alt_adc_register_callback" (Which doesn't make sense to me... Why do we need it?). Also, I put a "alt_adc_word_read" afterwards cause when I enter the while loop my code does not go to the ISR, which was supposed to go (as I wished). The ISR declaration isstatic void alt_ic_isr(void* context, alt_u32 id). int main(void){
//Shown at the GUI that the program has started
printf("*** The ADC has started ***\n");
alt_u32 *adc_data_ptr;
alt_u32 line_in_data;
printf("*** Configure and start the sample_store config ***\n");
void* edge_capture_ptr = (void*) &edge_capture;
altera_modular_adc_init(edge_capture_ptr,
MODULAR_ADC_SAMPLE_STORE_CSR_IRQ_INTERRUPT_CONTROLLER_ID,
MODULAR_ADC_SAMPLE_STORE_CSR_IRQ
);
/* Arguments:
* - *dev: Pointer to adc device (instance) structure.
* - callback: Pointer to callback routine to execute at interrupt level
- *context: Pointer to adc device structure.
* - sample_store_base: Base address of the sample store micro core.
* */
alt_adc_callback adc_callback_ptr;
alt_modular_adc_dev* devIRQ;
devIRQ=altera_modular_adc_open (MODULAR_ADC_SAMPLE_STORE_CSR_NAME);
alt_adc_register_callback(
devIRQ,
adc_callback_ptr,
edge_capture_ptr,
MODULAR_ADC_SAMPLE_STORE_CSR_BASE
);
alt_adc_word_read (MODULAR_ADC_SAMPLE_STORE_CSR_BASE, adc_data_ptr, MODULAR_ADC_SAMPLE_STORE_CSR_CSD_LENGTH);
int adcSampleStorageIRQStatus=10;
int adcInterruptAsserted=10;
printf("*** All enabled ***\n");
while(1){
adcSampleStorageIRQStatus=READ_ALTERA_MODULAR_ADC_SAMPLE_STORAGE_IRQ_STATUS(MODULAR_ADC_SAMPLE_STORE_CSR_BASE);
printf("IRQ Status: %d\n",adcSampleStorageIRQStatus);
adcInterruptAsserted=adc_interrupt_asserted(MODULAR_ADC_SAMPLE_STORE_CSR_BASE);
printf("Interrupt Asserted?: %d\n",adcInterruptAsserted);
}
return 0;
}
I've tried to do many different things, use different drivers and I just didn't get any result. Someone could help me out? Thanks!