CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

10f222 ADC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








10f222 ADC
PostPosted: Thu Sep 24, 2009 8:18 am     Reply with quote

Hi Guys

Has anyone got the ADC working on a 10f222 ? If so has anyone got any example code that I can look at ?

Pete
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 24, 2009 6:19 pm     Reply with quote

Here is demo program for the ADC on the 10F222. This was tested in
hardware with vs. 4.073.

A 10K trimpot was connected between +5v and ground. The wiper of
the trimpot was connected to the AN0 pin (GP0) on the 10F222. Pin GP2
was connected to the Rx pin (pin 2 on a DB9) on the COM1 port on the
PC. Pin 5 on the DB9 was connected to ground on the 10F222 board.
There is a 10K pull-up resistor on the MCLR pin.

While running the program, the trimpot was turned from one limit to
the other limit. The follow output was displayed in a terminal window
on the PC. This is correct output.
Quote:

0
0
19
58
88
117
128
154
191
232
255
255
255


Here is the demo program:
Code:

#include <10F222.H>
#fuses IOSC4,NOWDT,MCLR
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_B2, INVERT)

#define set_options(value)   {#ASM         \
                              MOVLW  value \
                              OPTION       \
                              #ENDASM}

//=========================
void main()
{
int8 result;

set_options(0xDF);  // Enable pin B2 for normal i/o

setup_adc_ports(sAN0);
setup_adc(TRUE);
set_adc_channel(0);
delay_us(20);

while(1)
  {
   result = read_adc();
   printf("%U \n\r", result);
   delay_ms(500);
  }

}
eabir



Joined: 16 Aug 2010
Posts: 19

View user's profile Send private message

PostPosted: Fri Oct 28, 2011 4:08 am     Reply with quote

ok,

but my question was what is the best way in coding in order to follow the count increament.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 28, 2011 11:13 am     Reply with quote

Please continue in your original thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=46620

In your original thread, post some more information about what you
mean by "follow the count".
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group