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