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

PIC18F87J10 internal ADC trouble

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







PIC18F87J10 internal ADC trouble
PostPosted: Thu Jul 19, 2007 1:06 pm     Reply with quote

I am trying to read an external potentiometer attached to AN0 as a kind of hello world for the AD, using Vdd/Vss as reference. The problem is that I have only constructed an elaborate random generator it seems. I want to use the internal acquisition timer to time the sampling.

Please have a look and tell me what I am doing wrong.

Code:

#byte ADRESH = 0xFC4
#byte ADRESL = 0xFC3
#byte ADCON0 = 0xFC2
#byte ADCON1 = 0xFC1
#byte ADCON2 = 0xFC0
#bit ADCAL = ADCON0.7
#bit ADGODONE = ADCON0.1
#bit ADON = ADCON0.0

{
  input(PIN_A0); //make inputs
  input(PIN_A1);
  input(PIN_A2);
  input(PIN_A3);
  input(PIN_A4);
  ADCON0 = 0b10000000; //cal, AN0
  ADCON1 = 0b00001010; //Vdd-Vss, AN4-AN0
  ADCON2 = 0b00111010; //20TAD, left justified, Tclk/32

  ADON = 1;
  ADGODONE = 1; //start calibration
  while (ADGODONE);
 
  ADCAL = 0; //normal mode
  ADGODONE = 1; //start first conversion
  while (ADGODONE);

  while (1) {
    while (ADGODONE);
    printf(Maxputc, "%x\n\r", ADRESH);
   
    delay_ms(100);
    MaxKeepMAX3110Alive();
    ADGODONE = 1;
  }
}
zilog
Guest







PostPosted: Thu Jul 19, 2007 2:06 pm     Reply with quote

I found it in the errata, now it works.
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