electronicsman
Full Member level 5
I am referring to the micro dspic33EP256MC506 and the ADC module. There is a configuration for simultaneous sampling of 4 channels that is CH0, CH1, CH2, CH3. Now my confusion is out of these 4 channels i may want only 2 channels, can i still do it? I mean to say the micro will still do it but i should not use it. Am I correct? Because my source code may change based on this. If i use channel 0 and channel 3. Please advise.
Code:
void __attribute__((interrupt, no_auto_psv)) _AD1Interrupt(void)
{
channel1 = ADC1BUF0;
channel3 = ADC1BUF3;
//Clear interrupt flag
IFS0bits.AD1IF = 0;
}
Code:
/* a. 10 bit
* b. 4 channel
* c. Simultaneous sampling
* d. PWM trigger
* f. Integer Format
* g. Converts CH0, CH1. CH2, CH3 simultaneously
* h. Does not scan inputs
* i. ADC interrupt is generated at the completion of every sample/conversion operation
* j. Always uses channel input selects for sample MUXA
* k. Clock derived from system clock
* l. AN1 -> CH2 -> Ia, AN11 -> CH0 -> Ib
*/
/* ADPCFG: ADC Port Configuration Register */
// Set all ports digital
TRISAbits.TRISA1 = 1;
ANSELAbits.ANSA1 = 1;
TRISCbits.TRISC11 = 1;
ANSELCbits.ANSC11 = 1;
/* Signed Fractional */
AD1CON1bits.FORM = 0;
/* PWM Generator 1 primary trigger compare ends sampling and starts conversion */
AD1CON1bits.SSRC = 0;
AD1CON1bits.SSRCG = 1;
/* Sampling begins immediately after last conversion */
AD1CON1bits.ASAM = 1;
/* Select 10-bit, Multiple ADC operation */
AD1CON1bits.AD12B = 0;
/* No channel scan for CH0+, Use MUX A, SMPI = 1 per interrupt, Vref = AVdd/AVss */
AD1CON2 = 0x0000;
/* Set Samples and bit conversion time */
AD1CON3 = 0x0304; /* Need to get more clarity*/
/* Disable DMA */
AD1CON4 = 0x0000;
/* No Channels to Scan */
AD1CSSL = 0x0000;
/* Negative voltage is AVDD AN1 -> CH2*/
AD1CHS123=0x0000;
/* Channel select AN11 */
AD1CHS0 = 11;
/* Reset ADC interrupt flag */
IFS0bits.AD1IF = 0;
/* Enable ADC interrupts, disable this interrupt if the DMA is enabled */
IEC0bits.AD1IE = 1;
/* Turn on ADC module */
AD1CON1bits.ADON = 1;