-
Notifications
You must be signed in to change notification settings - Fork 143
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
Basic ADC support for SAMx7x #935
Conversation
a05cd68
to
9cb62bf
Compare
%% if target.family == "e7x/s7x/v7x" | ||
// values from vendor hal code and application note | ||
// {{reg}}_MR_TRANSFER(1) is a forbidden value according to the datasheet | ||
{{reg}}_MR_TRANSFER(1) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But but it's forbidden???2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have completely stopped trusting the correctness of the ADC section in the datasheet. It states for the TRACKTIM
field:
"Inherent tracking time is always 15 AFE clock cycles. Do not modify this field."
If I follow their guidance and leave TRACKTIM
on the reset value of 0, the ADC will read values close to half scale about 50% of the time when its input is connected to GND.
The examples in the app note number 44046 ("Using the Analog Front End in the SAM V7/E7/S7
MCUs") use AFEC_MR_TRACKTIM(2)
which according to the text means TRACKTIM + 1 = 3
AFE clock cycles which is not at all equal to 15. That example also has the illegal value of AFEC_MR_TRANSFER(1)
. Those values are also what the ASF3 vendor HAL has as defaults.
Assuming the app note is right about the meaning of the TRACKTIM
field it has to be set to 14 to achieve the recommended tracking time of 15 AFE clock cycles.
There are actually 3 different vendor HAL options offered right now, ASF3, ASF4 and MPLAB Harmony.
ASF4 can only be obtained by registering and downloading a Windows IDE, so I skipped it. The others can be found somewhere on github.
The MPLAB HAL has AFEC_MR_TRANSFER(2)
and AFEC_MR_TRACKTIM(15U)
which would equate to 16 cycles if the app note was right.
This is all a bit too confusing. I'll go with AFEC_MR_TRACKTIM(14)
and the datasheet recommended value of AFEC_MR_TRANSFER(2)
until proven otherwise. At least the ADC seems to do the right thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ERMAHGERD 🙄
9cb62bf
to
7330500
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
Whoops, forgot about this, sorry! |
Extend basic SAMG55 ADC driver to support SAMx7x devices. The example has been tested in hardware. The peripheral instances follow the naming convention from the datasheet. There the ADC is called
AFEC
(analog front-end controller), but it will be provided by themodm:platform:adc
module for commonality reasons.Tested in hardware.