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

Analog input AN9 pin_B4 drives high (pic18f46k80)

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



Joined: 09 Aug 2018
Posts: 15

View user's profile Send private message

Analog input AN9 pin_B4 drives high (pic18f46k80)
PostPosted: Wed Mar 13, 2019 10:34 am     Reply with quote

Hi Everyone,

On our last project, we want to use pin_B4 as analog input. ADC is configured as:
Code:

setup_adc( ADC_CLOCK_INTERNAL );
setup_adc_ports( sAN1 | sAN4 | sAN6 | sAN7 | sAN9);
enable interrupts( INT_AD);

However the pin B4 is at 5V like if it was pulled up and therefore measurement is wrong.

If I erase the device pin_B4 is at 0V. Any idea on how to debug this?


Last edited by tolliug on Wed Mar 13, 2019 10:47 am; edited 1 time in total
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 13, 2019 10:45 am     Reply with quote

re:
1st comment:
Quote:
setup_adc( ADC_CLOCK_INTERNAL );
Usually 'ADC_CLOCK_INTERNAL' is for slow clocked PICs, and only when asleep, so checke the datasheet, adc section for a chart of legal adc clock config.

2nd comment:
Quote:
setup_adc_ports(sAN1 | sAN4 | sAN6 | sAN7 sAN9);
I don't see a '|' between sAN7 and sAN9
check for proper syntax..

3rd comment
Quote:
enable interrupts(INT_AD);
Be sure you have an interrupt handler (function) as enabling an interrupt without will cause the PIC to crash...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 13, 2019 11:24 am     Reply with quote

Post more of your program. Show us the code where you select aN9 as
the current channel to read. Show us the code in the read_adc() section
of your program.
Ttelmah



Joined: 11 Mar 2010
Posts: 19215

View user's profile Send private message

PostPosted: Wed Mar 13, 2019 11:30 am     Reply with quote

and (of course) there is absolutely no reason to use INT_AD, unless
you are starting the ADC conversion with perhaps a CCP. Otherwise
it takes longer to get into and out of an interrupt handler than it takes
to simply perform the conversion 'in line'.

Also, on the problem, I think there is a CTMU output on this pin. Any
configuration lines for this peripheral?.

Any code accessing the pull-ups?.
Everything that accesses TRISB, LATB, PORTB?.
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