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

Correcting ADMUX selection in __analogRead() #130

Closed
wants to merge 3 commits into from
Closed

Correcting ADMUX selection in __analogRead() #130

wants to merge 3 commits into from

Conversation

LaZsolt
Copy link
Collaborator

@LaZsolt LaZsolt commented Apr 2, 2021

  • ADMUX input source used a wrong mask. (was 0x0f instead 0x1f)
  • LGT8F328D ADMUX has less input than P version. If someone want to read these unselectable inputs, it will return zero ADC value.
  • V5D1 and VCCM is same input with different name

- ADMUX input source used a wrong mask. (was 0x0f instead 0x1f)
- LGT8F328D ADMUX has less input than P version. If someone want to read these unselectable inputs, it will return zero ADC value.
- V5D1 and VCCM is same input with different name
Copy link
Collaborator Author

@LaZsolt LaZsolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set default analogReadResolution to 10 bits.
#41

Copy link
Collaborator Author

@LaZsolt LaZsolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary round bracket deleted.

@frizzle101101
Copy link

is this why I'm getting 12bit default adc on projects

@dbuezas
Copy link
Owner

dbuezas commented May 19, 2021

Hey @LaZsolt !
This will be a breaking change, right? (10bt analg read by default)
I'll then release an intermediate version before, and then another one with this as v2.
Do you mind adding a small example sketch to switch between analogRead resolutions?

@LaZsolt
Copy link
Collaborator Author

LaZsolt commented May 19, 2021

This will be a breaking change, right?

Yes, but as @jayzakk mentioned in #41 the aduino default is 10 bits for backward compatibility with AVR based boards.

I think not necessary any example sketch, because it is a normal Arduino analog API extended function for those boards which have 12 bits ADC.
Documentation: https://www.arduino.cc/en/Reference.AnalogReadResolution

It may be unpleasant for those users who will be upgrading dbuezas/lgt8fx core.

@dbuezas
Copy link
Owner

dbuezas commented May 19, 2021

Gotcha. I'll make a release without, and then merge this one and move to v2 following semver

@LaZsolt
Copy link
Collaborator Author

LaZsolt commented May 20, 2021

But this request is not mainly about AnalogReadResolution.

In this line below, because of the bitmask of pin variable, only 8 analog inputs reachable. (A0 - A7)

ADMUX = (analog_reference << 6) | (pin & 0x07);

With my correction more inputs will be readable: PIN_A8, PIN_A9, PIN_A10, PIN_A11, IVREF, AGND, DACO, 1/5 AVCC, 4/5 AVCC

@dbuezas
Copy link
Owner

dbuezas commented May 20, 2021

Oh, so this is not breaking change then. Should i merge now?

@LaZsolt
Copy link
Collaborator Author

LaZsolt commented May 20, 2021

This pull request is two in one.
1st - expanding ADMUX pin select bitmask from 0x07 to 0x1F
2nd - changing the default resolution of analogRead() to 10 bits for Arduino compatibity reason.

  • So to get back the LGT8Fx 12-bit ADC capabilities, must change the resolution to 12 with AnalogReadResolution(12);. (At least in the setup function.)

I think it's acceptable. If you think the same then you should merge it.

@dbuezas
Copy link
Owner

dbuezas commented May 20, 2021

Oh got it. Then Ill hold it a bit and very soon make 2 releases. The first without and the second with (and that will be v2.0.0)

@navr32
Copy link

navr32 commented Jul 9, 2021

So this is the problem says why my A8 pin of wavgat board reject at build ?
Arduino : 1.8.15 (Linux), Carte : "LGT8F328, Default (64), Internal, 32 MHz, 328P-LQFP32 (e.g. MiniEVB nano-style and WAVGAT)"


'A8' was not declared in this scope


@LaZsolt
Copy link
Collaborator Author

LaZsolt commented Jul 10, 2021

@navr32
In LGT8F328P-LQF32 the A8, A9 and A11 analog inputs not connected to any pins. That's why not declared.
I assume the A8 name is wrong on the WAVGAT board. The real name coud be A6.

WAVGAT pro mini front-1

@navr32
Copy link

navr32 commented Jul 11, 2021

Hi LaZolt !
You assume very well ! I just come to test it and this is A6 so simple ...very annoying i haven't think to this..many thanks.

@LaZsolt
Copy link
Collaborator Author

LaZsolt commented Aug 4, 2022

Close this request, because #217 include the solution.

@LaZsolt LaZsolt closed this Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants