Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

dsPIC30f2010 ADC sampling PLZ!!

Status
Not open for further replies.

Jean-Pierre du Plessis

Newbie level 6
Joined
Dec 6, 2010
Messages
11
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,398
Hi can someone please help me. I changed my project. I am using all 6 ADC inputs. An internal volatage refrance. At the moment it is posible to sample and convert 4 of the 6 inputs. I sampling all 4 CH of the adc and then converting it. This is my adc setup code and adc reading code.


Code:
void enableADC(void) {
    ADCON1bits.ADON = 0;            //ADC Module is off
    ADCON3bits.ADCS = 2;            // TAD = TCY*(ADCS + 1); Tcy = 25ns; Min TAD = 75ns
    ADCON1bits.FORM = 0;            // Integer
    ADCON1bits.ADSIDL = 0;          //Discontinue module in idle mode
    ADCON1bits.SSRC = 7;            // Automatic Conversion Sequence
    ADCON1bits.SIMSAM = 1;          //Samples multiple channels in sequence
    ADCON1bits.ASAM = 0;            // Auto sampeling, after last sample

    ADCON2bits.VCFG = 0;            // VrefH = AVdd / VrefL = AVss
    ADCON2bits.CSCNA = 0;           // Scan inputs CH0+
    ADCON2bits.CHPS = 2;            // Channel CH0 CH1 CH2 conversance
    ADCON2bits.SMPI = 0;            // Increments the DMA address after completion of every sample/conversion operation
    ADCON2bits.ALTS = 0;            // Always use MUX A input multiplexer
    ADCON2bits.BUFM = 0;

    ADCHSbits.CH0SA = 3;            //Channel 0 Positive Input Select for MUX A Multiplexer Setting bits
    ADCHSbits.CH123SA = 0;          //Channel 1, 2, 3 Positive Input Select for MUX A Multiplexer Setting bit
    ADCHSbits.CH0NA = 0;            //Channel 0 Negative Input Select for MUX A Multiplexer Setting bit
    ADCHSbits.CH123NA = 0;          //Channel 1, 2, 3 Negative Input Select for MUX A Multiplexer Setting bits

    ADCON3bits.ADRC = 0;            // ADC Clock Derived from System Clock
    ADCON3bits.SAMC = 1;            // Auto Sample Time bits TAD

    ADCON1bits.ADON = 1;            // Turn ADC on
    ADCON1bits.SAMP = 1;            //Start sampeling
    return;
}


    ADCON1bits.DONE = 0;
 
        ADCON1bits.SAMP = 1;                // Start Conversion
        while (!ADCON1bits.DONE);           // Wait for convert
        Nop();

My question is how do I sample all 6 inputs and convert them to go and read them out of the buffers. I tried using the example on page of the refrance manual. I am not sure how to use the interupt bit. When it will be set. Please help me.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top