Hot!PIC32MZ EF ADC interrupt set up or the MC datashit saga

Author
MarkoAnte
Senior Member
  • Total Posts : 146
  • Reward points : 0
  • Joined: 2015/03/23 01:46:38
  • Location: 0
  • Status: offline
2016/07/19 02:26:40 (permalink)
0

PIC32MZ EF ADC interrupt set up or the MC datashit saga

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: 
void __ISR(_ADC_VECTOR, IPL4SRS) xyz (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 edited by MarkoAnte - 2016/07/21 01:18:15
#1

5 Replies Related Threads

    MarkoAnte
    Senior Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/03/23 01:46:38
    • Location: 0
    • Status: offline
    Re: PIC32MZ EF ADC interrupt set up 2016/07/20 05:42:57 (permalink)
    0
    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
    #2
    MarkoAnte
    Senior Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/03/23 01:46:38
    • Location: 0
    • Status: offline
    Re: PIC32MZ EF ADC interrupt set up 2016/07/20 08:23:42 (permalink)
    0
    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?
    #3
    MarkoAnte
    Senior Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/03/23 01:46:38
    • Location: 0
    • Status: offline
    Re: PIC32MZ EF ADC interrupt set up 2016/07/21 01:08:38 (permalink)
    0
    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. 
    #4
    Taïga
    New Member
    • Total Posts : 29
    • Reward points : 0
    • Joined: 2015/03/17 14:00:17
    • Location: Belgium
    • Status: offline
    Re: PIC32MZ EF ADC interrupt set up 2018/07/11 14:12:17 (permalink)
    0
    Hello Marko,
     
    i saw your post on the PIC32MZ ADC interrupt here:
     
    https://www.microchip.com/forums/m939603.aspx?high=ADCEIOVR
     
    Did you finally get the ADC interrupt working, by setting ADCEIOVR to 1 ?
    And did you try to get the ADC interrupt working by setting ADCGIRQEN1bits.AGIEN0, without any early interrupt ? 
     
    I am trying to get working ADC interrupts with the PIC32MZ2048EFH100 for many hours, and i meet many issues...
    And there is almost no information on that topic on the forum
    That's why i would be interrested to know if you managed to get ADC interrupts working... 
     
    Best regards,
     
    Taïga
    #5
    MarkoAnte
    Senior Member
    • Total Posts : 146
    • Reward points : 0
    • Joined: 2015/03/23 01:46:38
    • Location: 0
    • Status: offline
    Re: PIC32MZ EF ADC interrupt set up 2018/07/15 02:19:32 (permalink)
    0
    I did get it to run but I have forgotten what I did to fix the problem. Did you solve  your problems ? 
     
    #6
    Jump to:
    © 2018 APG vNext Commercial Version 4.5