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 support@ccsinfo.com

ADC of PIC18F4431, help me. Please!

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 27, 2009 12:57 pm     Reply with quote

Use the program shown below. It works. I turned the 10K trimpot
on Pin A0 so it goes from the lower limit to the upper limit. Here is
the output. It's correct.
Quote:

0000
0000
0056
00A9
0104
0169
01AF
02BC
0335
03E3
03FF
03FF
03FF


Here is the test program. It's running on a PicDem2-Plus board and
was compiled with PCH vs. 4.099:
Code:

#include <18F4431.h>
#device adc=10
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=20000000) 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

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

setup_adc_ports(sAN0);
setup_adc(ADC_CLOCK_DIV_32);
set_adc_channel(0);
delay_us(15);

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

}
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Sun Sep 27, 2009 2:59 pm     Reply with quote

nhamdtk4 wrote:
I have tryed it but it is false with 18F4431. So I don't understand what must i do if i use 18F4431.


Are the AVdd and AVss pins connected?

AVdd to Vdd, and AVss to Vss.
nhamdtk4



Joined: 18 May 2009
Posts: 8
Location: Việt Nam

View user's profile Send private message

PostPosted: Fri Oct 02, 2009 4:07 am     Reply with quote

Thank PCM programmer, thank Kenny very much. I have resolved my problem.
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