Friday, March 1, 2013
Conversión Analógico Digital CCS
/////////////////////////////////////////////////////////////////////////
//// ////
//// This program displays the min and max of 30 A/D samples over ////
//// the RS-232 interface. The process is repeated forever. ////
//// ////
//// If required configure the CCS prototype card as follows: ////
//// Insert jumper from output of POT to pin A5 ////
//// Use a 10K POT to vary the voltage. ////
//// ////
//// Jumpers: ////
//// PCM,PCH pin C7 to RS232 RX, pin C6 to RS232 TX ////
//// PCD none ////
//// ////
//// This example will work with the PCM, PCH, and PCD compilers. ////
//// The following conditional compilation lines are used to ////
//// include a valid device for each compiler. Change the device, ////
//// clock and RS232 pins for your hardware if needed. ////
/////////////////////////////////////////////////////////////////////////
#include <30f5011 .h="">30f5011>
#fuses HS,NOWDT
#use delay(clock=20000000)
#use rs232(baud=9600, UART1)
void main() {
int i, value, min, max;
printf("Sampling:");
setup_adc_ports( sAN0 );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );
do {
min=255;
max=0;
for(i=0; i<=30; ++i) {
delay_ms(100);
value = read_adc();
if(valuemax)
max=value;
}
printf("nrMin: %2X Max: %2Xnr",min,max);
} while (TRUE);
}
Currently have 0 comentarios: