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

adc 12 bit #110

Open
iddq opened this issue Sep 11, 2020 · 2 comments
Open

adc 12 bit #110

iddq opened this issue Sep 11, 2020 · 2 comments

Comments

@iddq
Copy link

iddq commented Sep 11, 2020

Why is it converted to 10 bit if the next line assumes it is 12 bit wide.

ulValue = adc12b_get_latest_value(ADC12B) >> 2;

@matthijskooijman
Copy link
Collaborator

At first glance, seems like a bug to me. I thought that maybe adc12b_get_latest_value would return a zero padded value, but it seems to just return the LCDR register as-is:

uint32_t adc12b_get_latest_value(const Adc12b *p_adc)
{
return p_adc->ADC12B_LCDR;
}

And that register contains the 12-bit ADC value in the lower 12 bits:

image

(Note that the upper 4 bits can contain the channel number, but only if enabled, so I suspect this is not the case here and these are always zero and can be ignored).

Do you happen to have a Due you could test if this is indeed broken? Should be easy, if all analogRead values for these pins are off by a factor four, then it is really a bug.

@iddq
Copy link
Author

iddq commented Sep 11, 2020

I can't test it. I don't have DUE with SAM3U4E

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

No branches or pull requests

2 participants