EasyManua.ls Logo

Microchip Technology dsPIC30F - How to Stop Sampling and Start Conversions

Microchip Technology dsPIC30F
738 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
dsPIC30F Family Reference Manual
DS70064C-page 17-18 © 2004 Microchip Technology Inc.
17.12 How to Stop Sampling and Start Conversions
The conversion trigger source will terminate sampling and start a selected sequence of
conversions. The SSRC<2:0> bits (ADCON1<7:5>) select the source of the conversion trigger.
17.12.1 Manual
When SSRC<2:0> = 000, the conversion trigger is under software control. Clearing the SAMP
bit (ADCON1<1>) starts the conversion sequence.
Figure 17-4 is an example where setting the SAMP bit initiates sampling and clearing the SAMP
bit terminates sampling and starts conversion. The user software must time the setting and
clearing of the SAMP bit to ensure adequate sampling time of the input signal. See Example 17-1
for code example.
Figure 17-4: Converting 1 Channel, Manual Sample Start, Manual Conversion Start
Example 17-1: Converting 1 Channel, Manual Sample Start,
Manual Conversion Start Code
Note: The available conversion trigger sources may vary depending on the dsPIC30F
device variant. Please refer to the specific device data sheet for the available
conversion trigger sources.
Note: The SSRC selection bits should not be changed when the A/D module is enabled.
If the user wishes to change the conversion trigger source, the A/D module should
be disabled first by clearing the ADON bit (ADCON1<15>).
ADCLK
SAMP
ADCBUF0
TSAMP
TCONV
BCF ADCON1,SAMPBSF ADCON1,SAMP
Instruction Execution
DONE
ADPCFG = 0xFFFB; // all PORTB = Digital; RB2 = analog
ADCON1 = 0x0000; // SAMP bit = 0 ends sampling ...
// and starts converting
ADCHS = 0x0002; // Connect RB2/AN2 as CH0 input ..
// in this example RB2/AN2 is the input
ADCSSL = 0;
ADCON3 = 0x0002; // Manual Sample, Tad = internal 2 Tcy
ADCON2 = 0;
ADCON1bits.ADON = 1; // turn ADC ON
while (1) // repeat continuously
{
ADCON1bits.SAMP = 1; // start sampling ...
DelayNmSec(100); // for 100 mS
ADCON1bits.SAMP = 0; // start Converting
while (!ADCON1bits.DONE); // conversion done?
ADCValue = ADCBUF0; // yes then get ADC value
} // repeat

Table of Contents

Other manuals for Microchip Technology dsPIC30F