-
Notifications
You must be signed in to change notification settings - Fork 88
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
Modify pin number for A10 to match hardware; add C6 definition for re… #36
Conversation
A10/PE6 was defined for pin#26, not #25. Switched the two definitions, so that the analog functions can work with "A10" as constant. |
@dbuezas , can you please merge this one, so the pinout sheet matches? :-) (I see that I could merge that by myself now after the invite, but I rather would like to keep my fingers far away from the "merge" button. especially of my own commits ^^) |
Allright! I'm in vacations now, I'll merge, test and release when I'm back. |
@dbuezas , enjoy your vacation ;) |
Would you also add an example for this in the examples/lgt8f folder? 🙏 |
Hey @jayzakk, I added this patch to my core manually. Can you elaborate how A10 can be used then? The data sheet mentions PMX2 several times. Does PE6 default to GPIO or AVREF now? Similar doing What do we need to set to use it the same way as any other Ax pin? |
Just use the default Arduino functions for that, there isn't anything special in using the A10 line (after the patch, that is the reason I made a PR):
|
Thanks @jayzakk. I patched my core manually and measured voltage with a voltage divider on A10, which seems to work as expected. 12Bit resolution seems to be default though, but I set it anyways as per your suggestion. I used the following little sketch: const float reference = 2.048;
const float steps = 4064;
void setup() {
pinMode(A10, INPUT);
analogReference(INTERNAL2V048);
analogReadResolution(12);
Serial.begin(115200);
}
void loop() {
int value = analogRead(A10);
Serial.print(value);
Serial.print(" - ");
Serial.print((value / steps) * reference);
Serial.println("V");
delay(500);
} |
I did set the 12 bits, as I hope someone will fix #41 soon and I can rely on 10 bits default again ;) So you can confirm "just using" the A10 (like any other analogue pin) does work as intended? |
Yes, it seems to work fine on my little test board. I can't tell if it has any side effects though given it's "normal" use is AREF... |
(Which makes me think: the pin has 2 output modes: AREF and PE6. How to switch between them? I would expect, pinMode() switches function to PE6, but then there would be no way back to AREF. Time to dig deeper into the code) Edit: My fault. I used analogReference() function does some more magic: and any kind of pinMode() on E6/A10 does: So, my example worked, as the default PE6 mode is "input", and PE6 got enabled on the pin. That was luck. If PE6 would have been output, it may have killed the ADC0 ^^ |
Merging now :) |
…set line