Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
8 years ago

Max 10 ADC: Nios stuck at endless loop in alt_irq_handler()

Hi

I'm trying to get ADC to run with Deca Max 10 Evaluation board. When debugging the program in Nios, it appears to get stuck in the alt_irq_handler() function.

  
  active = alt_irq_pending ();
  do
  {
    i = 0;
    mask = 1;
    /*
     * Test each bit in turn looking for an active interrupt. Once one is 
     * found, the interrupt handler asigned by a call to alt_irq_register() is
     * called to clear the interrupt condition.
     */
    do
    {
      if (active & mask)
      { # ifdef ALT_ENHANCED_INTERRUPT_API_PRESENT
        alt_irq.handler(alt_irq.context); # else
        alt_irq.handler(alt_irq.context, i); # endif
        break;
      }
      mask <<= 1;
      i++;
    } while (1);
    active = alt_irq_pending ();
    
  } while (active);# endif /* ALT_CI_INTERRUPT_VECTOR */

I have no clue why it's stuck here???? Following is my simple code for reading ADC in main() function and attached file is the Qsys configuration.

    
    int count = 0;
    alt_u32 adc_data;
    /* Initialize adc */
    adc_stop(ADC_SEQUENCER_CSR_BASE); 
    adc_interrupt_disable(ADC_SEQUENCER_CSR_BASE);    // Disable interrupt
    adc_clear_interrupt_status(ADC_SEQUENCER_CSR_BASE);
    adc_set_mode_run_continuously(ADC_SEQUENCER_CSR_BASE);    // Set ADC run mode
    adc_start(ADC_SEQUENCER_CSR_BASE);        // start sampling
    for(alt_u32 sampleCnt=0; sampleCnt<100; sampleCnt++)    // read 1000 samples
    {
        alt_adc_word_read(ADC_SAMPLE_STORE_CSR_BASE, adc_data, ADC_SAMPLE_STORE_CSR_CSD_LENGTH);
        count++;
    }
    adc_stop(ADC_SEQUENCER_CSR_BASE);    // Stop ADC sampling
    while (1);

Any help would be really appreciated.

Thankshttps://alteraforum.com/forum/attachment.php?attachmentid=13911&stc=1
No RepliesBe the first to reply