Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on variant #727

Closed
fpistm opened this issue Oct 24, 2019 · 5 comments
Closed

Question on variant #727

fpistm opened this issue Oct 24, 2019 · 5 comments
Labels
answered question ❓ Usually converted as a discussion

Comments

@fpistm
Copy link
Member

fpistm commented Oct 24, 2019

Hi, could you expand a bit the Add new board wiki with info about how to set properly the analogs?, because I'm having problems with my variant for the F030C8, when I tried to read PA0 ( analogRead(PA0) ) it really reads the PA3, for the moment I solve it by using analogRead(PA_0). So I was under the impression that only has to match the:
NUM_ANALOG_FIRST on the variant.h file with the duplicates on the digitalPin array on variant.cpp, but it seems that may be more to it, right?. Thanks.

Originally posted by @r-pv in #722 (comment)

@fpistm
Copy link
Member Author

fpistm commented Oct 24, 2019

Hi @r-pv
you issue is that some analog pins have an number less than NUM_ANALOG_INPUTS
in your case it is equal to 10. So when you request PA0 you get this value:
#define PA0 3
which in fact in the Ax equivalent to A3 .
All Analog pin PYn must have a number greater or equal to NUM_ANALOG_INPUTS
This is what it means here
// First analog pin value (A0) must be greater than or equal to NUM_ANALOG_INPUTS

Maybe it could be rewrote like that:
// First analog pin value (A0) and all analog pin PYn must have a number greater or equal to NUM_ANALOG_INPUTS

@fpistm fpistm added the question ❓ Usually converted as a discussion label Oct 24, 2019
@r-pv
Copy link

r-pv commented Oct 24, 2019

Thanks for the reply, ups I got that wrong, I was thinking that the number was referring to the duplicates index and that was the reason they were written at last of the digitalPin array.

@fpistm
Copy link
Member Author

fpistm commented Oct 24, 2019

The reason to duplicate is to have all analog pins contiguous in order to be able to loop on it:

for (int i=0; i< NUM_ANALOG_INPUTS; i++) {
Serial.print(analogRead(i);
}

If in your definition they already are contiguous hen no need to duplicate.

@r-pv
Copy link

r-pv commented Oct 24, 2019

awesome, mr @fpistm, I can fix my variants now. And sorry for keep taking your time.

@fpistm
Copy link
Member Author

fpistm commented Oct 24, 2019

Welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered question ❓ Usually converted as a discussion
Projects
None yet
Development

No branches or pull requests

2 participants