Converting ADC from DUE to GIGA R1

I am currently attempting to convert a project from a DUE to GIGA R1. The code samples the ADC at what I believe is 1MHz, applies a low pass filter. I have most of the functionality completed but, I am having some issues with getting the ADC to sample at the correct rate. I this is the original code:

void ADC_Handler() {

    int adc_stat= adc1.ADC_ISR
    //int adc_stat = ADC->ADC_ISR;
    
    if (adc_stat & ADC_ENDRX) {
        //
        // Show that we've filled a buffer with ADC samples.
        //
        buf_full = true;
        ADC->ADC_CR = ADC_SWRST;
    }
}

//
// Prep the ADC for acquisition.
//
void adc_setup (void) {
    
    //
    // Init ADC for 1 MHz acquisition.
    //
    adc_init (ADC1, SystemCoreClock, 21000000, 10000);
    //
    // Set ADC to be free running.
    //
    ADC->ADC_MR |= 0x80;
    //
    // ADC channel 7 maps to Due analog pin 0.
    //
    ADC->ADC_CHER = ADC_CH7;
    NVIC_EnableIRQ (ADC_IRQn);
    
    //
    // There is no next buffer - only one.
    //
    ADC->ADC_RNPR = NULL_BUF;
    ADC->ADC_RNCR = 0;
    
    //
    // Enable receiver DMA.
    //
    ADC->ADC_PTCR = ADC_PTCR_RXTEN;
    
    //
    // Point to the sample buffer.
    //
    ADC->ADC_RPR = (uint32_t) sample_buf;
    
    //
    // Enable ADC conversions.
    //
    ADC->ADC_CR = ADC_START;
    
    //
    // Show waiting on the buffer to fill.
    //
    buf_full = false;
}

void adc_start (unsigned int num_samples) {
    //
    // Start the ADC by (re)loading the conversion count.
    //
    ADC->ADC_RCR = num_samples;
    //
    // We have to enable the ENDRX interrupt AFTER we load RCR, else we'll get an interrupt the
    // moment we enable the interrupt because ENDRX trips when RCR == 0 and that's what it will
    // be until we load it.
    //
    ADC->ADC_IER = ADC_ENDRX;

    //
    // Wait for the ADC isr to show the buffer full.
    //
    while (!buf_full);
}

void do_sample (void) {
    unsigned long holdoff = millis () + 0;
    sendcounts(9999);
    //
    // Do the ADC setup - we're doing this in parallel with holding off the start of the
    // acquisition so it doesn't cost anything.
    //
    adc_setup ();
    //
    // Delay from the recognition of the TRIGGER signal to let the ball get close to
    // the force sensor before we start acquiring data from the ADC.
    //
    while ((long) (millis () - holdoff) < 0);
    //
    // Start the acquisition and wait for it to complete.
    //
    adc_start (NUM_SAMPLES_PER_BUF);
    //
    // Do the processing and output the result.
    //
    do_filter (NUM_SAMPLES_PER_BUF);
    sendcounts (threshold (findpeak (), threshold_limit));
    
    //
    // Reset the trigger flag to prepare for the next acquisition.
    //
    trigger = false;
}

Some items like the ADC ISR stuff does not seem to exist in the GIGA AdvancedADC. Looking for information or links to what I am missing.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.