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

pic16f88 adc bug??

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







pic16f88 adc bug??
PostPosted: Sun May 28, 2006 12:27 pm     Reply with quote

Code:
#include <16F88.h>
#device adc=8
#fuses XT,NOWDT,PROTECT,NOBROWNOUT,PUT,MCLR
#use delay (clock=4000000)
#use rs232(baud=9600, xmit=PIN_B5, rcv=PIN_B2)

//int16 result;

main()
{
setup_adc( ADC_CLOCK_DIV_4);
setup_adc_ports(sAN0|VSS_VDD);
set_adc_channel(sAN0);



while(1)
{
   
   delay_ms(500);
  // result = read_adc();

   printf("TEST: %x",read_adc());
   
output_high(PIN_B4);
delay_ms(500);
output_low(PIN_B4);
delay_ms(500);

}
}


The ADC won't work if ur analog signal is inputted to pin 17/ AN0 but it will work if u use pin 18/AN1. weird. Seems like the adc channel are shifted up one port. If u put A0, its actually A1.

here's what in the pic16F88.h for adc section.

#define sAN0 1 //| A0
#define sAN1 2 //| A1
#define sAN2 4 //| A2
#define sAN3 8 //| A3
#define sAN4 16 //| A4
#define sAN5 32 //| B6
#define sAN6 64 //| B7
#define NO_ANALOGS 0 // None



Is there something with the way i declare the ADC or is this a bug?? I'm using v3.202
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 28, 2006 2:43 pm     Reply with quote

Quote:
set_adc_channel(sAN0);
Seems like the adc channel are shifted up one port. If u put A0, its actually A1.



Here is what the CCS manual says about the parameters that
can be used with the set_adc_channel() function:
Quote:
set_adc_channel (chan)

chan is the channel number to select. Channel numbers start at 0.

Examples:
set_adc_channel(2);

Compare your parameters with the ones that the manual says to use.
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