CCS News

Using the Advanced Analog-to-Digital Converter (ADC) of the dsPIC33EPxxGS50x

Monday 14 March, 2016

There is a chance that you will need to read multiple analog signals at once or are the analog signals you are reading too small? The dsPIC3EPxxGS50x family of microcontrollers solve both of these problems, and the CCS C Compiler makes it easy to use. This family of chips have new ADC capable of sampling up to 5 analog inputs simultaneously. With the addition of two new functions for setting up the dedicated ADC cores, the Compiler makes it simple to read a single channel or multiple channels simultaneously. The following is an example of how to setup the ADC to read AN0 using the Dedicated ADC Core 0:

setup_adc_ports(sAN0, VSS_VDD);

setup_adc(ADC_CLOCK_SYSTEM | ADC_CLOCK_DIV_1 | ADC_WARMTIME_512);

setup_dedicated_adc(0, ADC_DEDICATED_CLOCK_DIV_2 |
ADC_DEDICATED_TAD_MUL_257 |
ADC_DEDICATED_CORE_CONV_DELAY);

set_dedicated_adc_channel(0, ADC_CHANNEL_AN0);

while(TRUE)
{
ADCReading = read_adc(ADC_START_AND_READ, 0);
...
}

Since the dsPIC33EPxxGS50x family of devices have individual Data Ready Status flags and Buffer registers for each analog channel, an optional second parameter was added to the read_adc() function to specify the channel to read. This allows for quicker reads with far less code generated to determine the flag to test and buffer to read.

Additionally the dsPIC33EPxxGS50x family have two Programmable Gain Amplifiers (PGA). The PGA is an op amp based non-inverting amplifier that can be used to amplify small voltages by 4x, 8x, 16x, 32x or 64x to improve the signal-to-noise ration of the measured signal. The PGA output voltage can then be read by one of the dedicated cores of the of the ADC, or used as an input to the Analog Comparator.

The new built-in functions are available in IDE compilers and the PCM command-line compilers starting with version 5.056.

Like us on Facebook. Follow us on Twitter.

About CCS:

CCS is a leading worldwide supplier of embedded software development tools that enable companies to develop premium products based on Microchip PIC® MCU and dsPIC® DSC devices. Complete proven tool chains from CCS include a code optimizing C compiler, application specific hardware platforms and software development kits. CCS' products accelerate development of energy saving industrial automation, wireless and wired communication, automotive, medical device and consumer product applications. Established in 1992, CCS is a Microchip Premier 3rd Party Partner. For more information, please visit http://www.ccsinfo.com.

PIC® MCU, MPLAB® IDE, MPLAB® ICD2, MPLAB® ICD3 and dsPIC® are registered trademarks of Microchip Technology Inc. in the U.S. and other countries.