Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6652261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:06:52+00:00 2026-05-26T01:06:52+00:00

I am using a PIC32MX534F064L ( datasheet ), and trying to read several of

  • 0

I am using a PIC32MX534F064L (datasheet), and trying to read several of its analog pins (marked AN0 to AN15).

With none of those pins connected to anything, I expect to read a value of zero. Instead on AN0 through AN5 I read values between 650 and 900. Only from the rest (AN6 through AN15) I get a value of zero.

When each of the pins is connected to a source, they report correctly. Each of the pins, AN0 through AN15 will report 0 for 0.0V, and 1023 for 3.3V.

I’ve tried sampling the values in pairs, and each separately. Whether sampled together or apart, AN0 will report non-zero values (usually around 700-800), and AN13 will report 0.

My first thought was that I somehow failed to properly set up the ADC. Here’s my code:

#include <stdio.h>
#include <plib.h>

unsigned int an0;
unsigned int offset;
char buffer[100];

int main(void)
{
  SYSTEMConfigPerformance(72000000L);
  CloseADC10();

  #define ADC_CONFIG1 ADC_MODULE_ON | ADC_FORMAT_INTG | \
                      ADC_CLK_AUTO | ADC_AUTO_SAMPLING_ON
  #define ADC_CONFIG2 ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | \
                      ADC_SCAN_OFF | ADC_SAMPLES_PER_INT_2 | \
                      ADC_ALT_BUF_ON | ADC_ALT_INPUT_ON
  #define ADC_CONFIG3 ADC_CONV_CLK_INTERNAL_RC | ADC_SAMPLE_TIME_15
  #define ADC_CONFIGSCAN SKIP_SCAN_ALL
  #define ADC_CONFIGPORT ENABLE_AN0_ANA

  SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF | ADC_CH0_POS_SAMPLEA_AN0 );
  OpenADC10( ADC_CONFIG1, ADC_CONFIG2, ADC_CONFIG3, \
             ADC_CONFIGPORT, ADC_CONFIGSCAN );
  EnableADC10();

  while ( ! mAD1GetIntFlag() ) { }

  while (1)
  {
    offset = 8 * ((~ReadActiveBufferADC10() & 0x01));
    an0 =  ReadADC10(offset);
    sprintf(buffer, "AN0 = %u", an0);
  }

  return 0;
}

Looking in the PIC’s datasheet, I noticed two things:

  1. The pins AN0 to AN5, the ones mis-reporting non-zero values, are also CNx pins. These pins are “Change Notification” pins, that are meant to raise an interrupt when the value on the pins changes.

  2. There is a “weak pull-up” that can be enabled on all CNx pins.

So I tried disabling the “weak pull-up” by using this line:

mCNClose();

Which disables all the CNx pins and their pull-ups. Sadly, this did not help. And when I checked the value of the CN-pull-up-register (CNPUE

What else can I try? Am I doing something wrong in my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:06:53+00:00Added an answer on May 26, 2026 at 1:06 am

    Well, your expectation is wrong!

    The minimum input resistance for source should be only few kilo ohms check datasheet.
    If ADC pins is floating (not connected) the unpredicted value of internal parasitic current will cause that measuring value will be bigger than 0. Remember the ADC sample capacitor has only few pF capacity so floating pins can oscillate in wide voltage range also from external EM (electromagnetic) influences.
    So, connect at least 1M resistors to pull down voltage on ADC pin, the resistance of pull down resistor is depended of ADC sample time. If ADC sample time is short than decrease the pull down value of resistor.

    EDIT:
    Check datasheet page 214 parameter AD17: Recommended Impedance of Analog Voltage Source is 5 KOhms. And AD15 say that that max. Leakage Current on ADC input pins can be +/-0.61 uA.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using linq2sql I'm trying to take the string in txtOilChange and update the oilChange
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using Rails 3.2.0 with haml, sass and coffeescript: Basically I am trying to disable
Using jQuery UI Resizable I'm trying to prevent resizing based on various rules. The
Using Javascript I'm trying to loop through a 3 level nested array with the
Using online interfaces to a version control system is a nice way to have
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using TortoiseSVN against VisualSVN I delete a source file that I should not have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.