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.

How can I read analog values with dsPIC?

Status
Not open for further replies.

anksyete

Newbie level 5
Joined
Nov 22, 2005
Messages
8
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,356
hi,

how can I read analog values with dsPIC?

can anyone send a sample C code?

thanks...
 

dspic adc example

Example 17-5: Converting 4 Channels, Auto-Sample Start,
TAD Conversion Start, Simultaneous Sampling Code
ADPCFG = 0xFF78; // RB0,RB1,RB2 & RB7 = analog
ADCON1 = 0x00EC; // SIMSAM bit = 1 implies ...
// simultaneous sampling
// ASAM = 1 for auto sample after convert
// SSRC = 111 for 3Tad sample time
ADCHS = 0x0007; // Connect AN7 as CH0 input
ADCSSL = 0;
ADCON3 = 0x0302; // Auto Sampling 3 Tad, Tad = internal 2 Tcy
ADCON2 = 0x030C; // CHPS = 1x implies simultaneous ...
// sample CH0 to CH3
// SMPI = 0011 for interrupt after 4 converts
ADCON1bits.ADON = 1; // turn ADC ON
while (1) // repeat continuously
{
ADC16Ptr = &ADCBUF0; // initialize ADCBUF pointer
OutDataPtr = &OutData[0]; // point to first TXbuffer value
IFS0bits.ADIF = 0; // clear interrupt
while (IFS0bits.ADIF); // conversion done?
for (count = 0; count < 4; count++) // save the ADC values
{
ADCValue = *ADC16Ptr++;
LoadADC(ADCValue);
}
} // repeat

Added after 4 minutes:

You can see the "Section 17. 10-bit A/D Converter" from Microchip
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top