--0__=80256AF40048F58A8f9e8a93df938690918c80256AF40048F58A Content-type: text/plain; charset=us-ascii Hi, Shouldnt the #use delay(clock=10000000) be 20000000 as I am using a 20MHz clock? * If your processor is running at 20MHz, then yes. Also, the delay of 100ms. Why have you chosen this, is it the time for the pic to register and process the analogue to digital conversion, so after 100mS it is ready to sample again? * You asked for some example code to show the CCS built-in functions and that is what I posted - maybe I got the wrong end of the stick but you did not ask for code for a specific application...Do you have the CCS compiler already ? I posted that to show the "ease" of using the inbuilt functionality with respect to on board hardware not to provide a solution. The delay is simply there to allow the A2D conversion to take place - the precise time it takes will be available in the PIC documentation. You could poll the conversion complete flag (or get an interrupt) before getting the value from the ADC - it's up to you. I assume that the result of the conversion is stored in value. Say for example I nputed 2.5v into the PIC how can I actually see what this value is to ensure that the A2D is functioning correctly. * With the CCS compiler, you can printf statements to redirect output through the UART, via a serial cable (via a MAX232 etc) to a PC and use Hyperterminal to monitor it. If you put 2.5V on the A2D (and it was configured for 0-5V full range) then you would expect to see something like "7F" coming up in Hyperterminal. The example code I posted omits the setup of the serial port but it is as simple as : #use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7) Use then need to interface the PIC and PC via a MAX232 using these pins. Regards, Dan (Embedded "MATTHEWS, DEAN (D.)" @MITVMA.MIT.EDU> image moved 29/10/2001 12:50 to file: pic20803.pcx) Please respond to pic microcontroller discussion list Sent by: pic microcontroller discussion list To: PICLIST@MITVMA.MIT.EDU cc: Subject: Re: [PIC]: USING CCSC C COMPILER Security Level:? Internal Shouldnt the #use delay(clock=10000000) be 20000000 as I am using a 20MHz clock? Also, the delay of 100ms. Why have you chosen this, is it the time for the pic to register and process the analogue to digital conversion, so after 100mS it is ready to sample again? I assume that the result of the conversion is stored in value. Say for example I nputed 2.5v into the PIC how can I actually see what this value is to ensure that the A2D is functioning correctly. Dean Matthews Reliability Engineering Ford Engine Plant Bridgend South Wales, U.K Tel No:(01656)672597 Fax No:(01656)672558 Email: dmatth14@ford.com ` Please consider your environmental responsibility before printing this e-mail -----Original Message----- From: D Lloyd [mailto:dan.lloyd@GB.ABB.COM] Sent: 29 October 2001 12:04 To: PICLIST@MITVMA.MIT.EDU Subject: Re: [PIC]: USING CCSC C COMPILER Hi, "Does anybody have any example C programs using the CCSC compiler for using the onboard A2D converter on the PIC16F877." A derivative of one of CCS' own examples - presumably they won't mind me posting it if they sell a compiler on the back of it ;-) #use delay(clock=10000000) void main (void) { int value; setup_port_a( ALL_ANALOG ); // Next 3 lines are inbuilt functions setup_adc( ADC_CLOCK_INTERNAL ); set_adc_channel( 0 ); do { value = Read_ADC(); delay_ms(100); printf("\n\r%2X\r\n", value); } while (TRUE); } Regards, Dan -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads --0__=80256AF40048F58A8f9e8a93df938690918c80256AF40048F58A Content-type: application/octet-stream; name="pic20803.pcx" Content-Disposition: attachment; filename="pic20803.pcx" Content-transfer-encoding: base64 CgUBCAAAAABBADEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAABQgABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAA= --0__=80256AF40048F58A8f9e8a93df938690918c80256AF40048F58A-- -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads