We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I use the PEC to transfer data from the ADC and the EOP interrupt to reset the PEC pointers. As i understand you still need to have an end of conversion interrupt from the ADC to use the PEC EOP interrupt. Does anyone know which of the two interrupts should have greater priority or should they be the same?
I will start with the point of the EOP is to have a considerable lower priority than the interrupt level used by the PEC. Given your question I would recommend that the EOP should be lower (not in the same group) that the ADC conversion complete interrupt is. The second thing to remember is any interrupt in a group will NOT interrupt another if another within that group is already active. If two or more interrupts within a group become active at the same time then the highest wins. However, if a lower priority within the group is active and a higher interrupt now becomes ready it is held off until the lower one has finished.
In your situation given you are using continuous auto scan and planning to have both interrupts in the same group it makes no sense to me to use the EOP. Instead I would just use the ADC conversion complete to reset the PEC registers. So I wouldn't stop the ADC, just don't use the EOP.
Some comments to the interrupts with the PEC. 1) When the PEC count is greater than 1 you only get the PEC transfer 2) When the PEC count decrements to zero the PEC transfer will occur and then you can either have the EOP or ADC conversion complete (depending on your configuration). 3) When the PEC count is zero you will only get the ADC conversion complete interrupt no matter what you configured for the EOP.
Hope this helps.
#include <XC167.h> /* Special Function Registers XC167 */ #include <intrins.h> unsigned int results[16]; unsigned int adcCnt; void ADC_Conv_ISR(void) interrupt 0x28 { DSTP0 = _sof_(&results[0]); PECC0 = 0x0210; adcCnt++; P2 ^= 0x100; /* toggle port pin */ } void main (void) { /* setup ADC, autoscan signle conversion of all 16 channels */ ADC_CON = 0x023F; ADC_CON1 = 0x8000; PECC0 = 0x0210; SRCP0 = _sof_(&ADC_DAT); DSTP0 = _sof_(&results[0]); PECSEG0 = 0; P5DIDIS = 0xFCFF; ADC_CIC = 0x0078; /* ADC Conv: (ILVL) = 14, (GLVL) = 0, (GPX) = 0 */ DP2 |= 0x100; /* use P2.8 to indicate an ADC service */ PSW_IEN = 1; /* globally enable interrupts */ ADC_CON_ADST = 1; /* begin the ADC conversions */ for(;;); }