On AVR32EB14 using PIN_PC0 for analogue input gives a compile error

Open Beginner friendly
#640 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
c
Domain
embedded-iot

Research direction

Start in variants/14pin-ebseries/pins_arduino.h and inspect the digitalPinToAnalogInput definition alongside the PIN_PC0 mapping. Reproduce the reported compile error with analogRead(PIN_PC0) on an AVR32EB14 using core 1.6.2, then verify the corrected mapping compiles successfully.

Written by the indexing model from the issue text.

Description

With core 1.6.2 compiling:

int test = analogRead(PIN_PC0);

gives the error:

/Users/david/Library/Arduino15/packages/DxCore/hardware/megaavr/1.6.2/cores/dxcore/wiring_analog.c:116:9: error: call to 'badArg' 
declared with attribute error: 
         badArg("analogRead called with constant pin that is only capable of digital input.");

I think the problem is that in variants/14pin-ebseries/pins_arduino.h:

#define digitalPinToAnalogInput(p)        (((p) >= PIN_PD4 && (p) <= PIN_PD7) ? (p) - PIN_PD0 : (((p) > PIN_PC0 && (p) <= PIN_PC3) ? (p) + 20 : NOT_A_PIN))

should be:

#define digitalPinToAnalogInput(p)        (((p) >= PIN_PD4 && (p) <= PIN_PD7) ? (p) - PIN_PD0 : (((p) >= PIN_PC0 && (p) <= PIN_PC3) ? (p) + 20 : NOT_A_PIN))
Dominant language
C
Stars
237
Forks
63
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SpenceKonde/DxCore

All issues in SpenceKonde/DxCore

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.