PIC32MZ EF ADC interrupt set up or MC datashit saga

PIC32MZ EF ADC interrupt set up or MC datashit saga

Postby MarkoAnte » Wed Jul 20, 2016 1:36 pm

Hi,

I'm trying to set up ADCs 0-4 to trigger at the same time on timer 5 and then via interrupt get their results, compute them afterwards and calculate the next state of the PWM signlas.
What would be the most efficient way to arhive this?
In the Section 22. data sheet it has this example:
Code: Select all
void __ISR(_ADC_VECTOR, ipl3)) ADCHandler1(void){
    /* call the corresponding ADC module handler */
    ((void(*)())*((int *)ADCBASE))();
}
//and then
void ADC0Handler(void)
{
/* Verify if data for AN0 is ready. This bit is self cleared upon data read */
    if(ADCDSTAT1bits.ARDY0)
    {
        ADC0Result = ADCDATA0;
    }
}


Why do they use this? If I understand the code _ADC_VECTOR is a general interrupt and than they shift the ADCBASE and get a address for an ISR for the desired result. But in the device data sheet the ADC Data 0 has its own _ADC_DATA0_VECTOR (if this is the ADC0 conversion complete - I can't find what this interrupt actuality does).
Also why don't they just under the _ADC_VECTOR check if ADCDSTAT1bits.ARDY0 == 1 and then do ADC0Result = ADCDATA0;? Is it so that less time is spend checking all ADCDSTAT1bits.ARDYx bits ?
So would it be the most efficient for me, to under the _ADC_VECTOR check (just to make sure) if all the results are ready. They should all be ready at ~ the same time - the possible latency delays would be covered by the time the program gets into interrupt right? Then I can save them for averaging and processing them out of the interrupt.

Best regards,
Marko

//Post also on the perpetually broken forum - http://www.microchip.com/forums/m939603.aspx
Last edited by MarkoAnte on Thu Jul 21, 2016 9:10 am, edited 1 time in total.
MarkoAnte
 
Posts: 7
Joined: Fri Jul 15, 2016 10:18 am
PIC experience: Professional 2-5 years with MCHP products

Re: PIC32MZ EF ADC interrupt set up

Postby MarkoAnte » Wed Jul 20, 2016 1:42 pm

Still having problems. Can not get an interrupt flag to set.
I can see that the IEC(ADCIE and ADCDOE) & ADCDSTAT1(ARDY0-ARDY4) & ADCGIRQEN1(AGIEN0-AGIEN4) bits are set. I can also see that there is a sensible result in the ADCDATA0.
I just get get and IFS1 bits to move.
Anybody have any idea why?

Best regards,
Marko
MarkoAnte
 
Posts: 7
Joined: Fri Jul 15, 2016 10:18 am
PIC experience: Professional 2-5 years with MCHP products

Re: PIC32MZ EF ADC interrupt set up

Postby MarkoAnte » Wed Jul 20, 2016 4:23 pm

Does anybody know where I could find an working example of a set up for an ADC with interrupt? I have look at the microchip example - but its in harmony (so its hard to locate the 1 missing bit I didn't set) and its for the PIC32MX chip. I still don't see what I'm missing. I have enabled the interrupts, set the priority, enabled interrupts in the ADC disabled early interrupts.
There is mention of logically ORin the interrupts to make a single global adc interrupt. Is this a special register somewhere that deals with it?
MarkoAnte
 
Posts: 7
Joined: Fri Jul 15, 2016 10:18 am
PIC experience: Professional 2-5 years with MCHP products

Re: PIC32MZ EF ADC interrupt set up

Postby MarkoAnte » Thu Jul 21, 2016 9:09 am

So I have made some head way.

ADCEIOVR: Early Interrupt Request Override bit
1 = Early interrupt generation is overridden and interrupt generation is controlled by the ADCGIRQEN1 and ADCGIRQEN2 registers
0 = Early interrupt generation is not overridden and interrupt generation is controlled by the ADCEIEN1 and ADCEIEN2 registers

but in the family datashit its

ADCEIOVR: Early Interrupt Request Override bit
1 = Early interrupt generation is not overridden and interrupt generation is controlled by the ADCEIEN1 and ADCEIEN2 registers
0 = Early interrupt generation is overridden and interrupt generation is controlled by the ADCGIRQEN1 and ADCGIRQEN2 registers

I did look in the family datashit if the bit was present & that it did the same thing, but I must have read it wrong on the first glance. Its just another day wasted because of the microchip datashit problem.

Hope it helps somebody sometime.

Marko

And no I did not misspell datasheet.
MarkoAnte
 
Posts: 7
Joined: Fri Jul 15, 2016 10:18 am
PIC experience: Professional 2-5 years with MCHP products


Return to PIC32 topics

Who is online

Users browsing this forum: No registered users and 7 guests