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

Using port B as analog input

 
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: Tue Jan 20, 2009 2:35 pm     Reply with quote

Try a simple test program like this (get rid of most of your code) and see
if it works. If it doesn't work, then post:
1. Your compiler version.
2. A description of the circuit connected to AN12 (pin B0).

Here's the test program:
Code:
#include <16F767.h>
#device adc=10
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

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

setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_DIV_16);
set_adc_channel(12);
delay_us(20);

while(1)
  {
   adc_value = read_adc();
   printf("%LU ", adc_value);
   delay_ms(500);
  }

}
robyvelez



Joined: 08 Dec 2008
Posts: 2

View user's profile Send private message

FIXED! (I think/hope)
PostPosted: Tue Jan 20, 2009 8:13 pm     Reply with quote

Thanks a lot for the reply. I tried the sample code you presented, but that still didn't work, and then I got to thinking about the compiler version.

I tried using a computer with a more updated version of the compiler. I'm an engineering student at a college and the computer I've claimed to use for my project had an old version of PIC C. Using a new version of the compiler the program seems to works fine. I'm going to ask ITS to update the version of PIC C on this computer and try it tomorrow, but I think using a more up to date compiler will do it. If not I'm sure you'll hear back from me again.
Guest








PostPosted: Sat Jan 24, 2009 7:39 am     Reply with quote

Hi

Remove the line setup_spi(false); this it not right.

Its the same as setup_spi(0) which is:
#define SPI_CLK_DIV_4 0

:-)
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