| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Mon Jun 07, 2010 11:21 am |   |  
				| 
 |  
				| Try a more simple program that will display ADC values from 0 to 1023 based on the input voltage.  Also, make sure you have a ground
 connection between the device that supplies the ADC input voltage and
 the PIC board's ground.   You can't just have the input signal wire to
 pin A0.   There must also be a ground wire between the two devices,
 connected to the ground on each device (or board).
 
  	  | Code: |  	  | #include <18F2525.h>
 #device adc=10
 #fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
 #use delay(clock=4000000)
 #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
 
 //============================
 void main()
 {
 int16 adc_value;
 
 setup_adc_ports(AN0);
 setup_adc(ADC_CLOCK_DIV_4);
 set_adc_channel(0);
 delay_us(20);
 
 while(1)
 {
 adc_value = read_adc();
 printf("%lu", adc_value);
 delay_ms(500);
 }
 }
 | 
 |  |