ADC_CHER configuration

7 years 10 months ago #490 by freddylamenace
Hi,

I'm a new user for arduino DUE and i have a problem for configuration : I want another POT for making special filtrers and I can't find explications for configuration of ADC_CHER[] and the while :

(extract from original code)
ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10
while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0)

Thanks.
The following user(s) said Thank You: AuDioChosis, ulf

Please Log in to join the conversation.

7 years 10 months ago #491 by Ray
Replied by Ray on topic ADC_CHER configuration
Hi,

Have a look at this link:
www.avrfreaks.net/forum/arduino-due-adc-channel-sequence

Its also good to understand how the ADCs are mapped in arduino DUE, in this image you can have a clear idea:
www.robgray.com/temp/Due-pinout-A4.png

You can see there how the ADC labeled on the board as "A0" is in fact the ADC7. This is how sometimes configuring that register is a bit confusing.

Also dont forget the DUE micorocontroller datasheet (SAM3X-SAM3A):
www.atmel.com/Images/Atmel-11057-32-bit-...-SAM3A_Datasheet.pdf

If you still have problems, let me know!
The following user(s) said Thank You: freddylamenace, AuDioChosis

Please Log in to join the conversation.

7 years 10 months ago #492 by freddylamenace
Hi,

thanks for you answer but i don't understand the relation between 0x1CC0 and the number of the channels.

For example, if i want a pot in channel 11 (AD 13), what is the argument for ADC_CHER ?

Thanks

Please Log in to join the conversation.

7 years 9 months ago #499 by Ray
Replied by Ray on topic ADC_CHER configuration
we want to enable ADCs 0, 1, 8, 9 and 10 that correspond to ADC7, AD6, AD10, AD11, AD12 respectively (you canverify it looking at this image www.robgray.com/temp/Due-pinout-A4.png).

Going to the datasheet page 1338 (www.atmel.com/Images/Atmel-11057-32-bit-...-SAM3A_Datasheet.pdf) you can see the ADC_CHER register, you can see that AD7, AD6, AD10, AD11 and AD12 correspond with bits 7, 6, 10, 11 and 12

if you take hits register (by default all zeroes) and place ones in the bits 6,7,10,11 and 12 you get 0011_1100_1100_0000 which is 0x1CC0 in hex.

If you want to add an extra pot in AD13 the binary would be 0011_1100_1100_0000 in hex 0x3CC0
The following user(s) said Thank You: freddylamenace, AuDioChosis, ulf

Please Log in to join the conversation.

6 years 3 months ago #1150 by AuDioChosis
Replied by AuDioChosis on topic ADC_CHER configuration
Hello and thanks for clarifying this. The original Pedal Due code had confused me:

ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 (???)

The comment says ADC channels but the numbers apparently refer to Arduino pin pad numbers.

And the SAM3 data sheet isn't all that clear. It uses the term "ADC channel" on page 1338 but refers to its pins as AD0..AD15 elsewhere. Plus the somewhat perverse mapping of Arduino pin pads and labeling adds more confusion.

The reality is that the pedal code assigns ADC_CHER=0x1CC0 which enables ADC channels 7, 6, 10, 11, & 12 ( not 0,1,8,9 and 10). However those ADC channels do correspond to Arduino pin pad numbers 0,1,8,9 and 10.

So if I wanted to use just ADC channel 0, I would assign ADC_CHER=0x0001
and connect my input to Arduino Dup pin pad number A7, yes?

Thanks again for helping with this issue.

Cheerio, Aaron[/size]

Please Log in to join the conversation.

6 years 3 months ago - 6 years 3 months ago #1151 by Ray
Replied by Ray on topic ADC_CHER configuration

The reality is that the pedal code assigns ADC_CHER=0x1CC0 which enables ADC channels 7, 6, 10, 11, & 12 ( not 0,1,8,9 and 10). However those ADC channels do correspond to Arduino pin pad numbers 0,1,8,9 and 10.

Yes, as I mentioned before the way the Atmel datasheet labels the ADCs is different from the Arduino labels. It is confusing yes, if you name them one way or the other, somebody is going to be confused.

So if I wanted to use just ADC channel 0, I would assign ADC_CHER=0x0001
and connect my input to Arduino Dup pin pad number A7, yes?

Yes, you are right.
The following user(s) said Thank You: AuDioChosis

Please Log in to join the conversation.

4 years 1 month ago - 4 years 1 month ago #2078 by ulf
Replied by ulf on topic ADC_CHER configuration
You post alone solved three of my problems! Thank you! Just a typo: the first binary should have one less 1, so 0001_1100_1100_0000. Easy enough to spot, but might help future visitors? Edit: this reply refers to post #499 by Ray

Please Log in to join the conversation.

Time to create page: 0.228 seconds
Powered by Kunena Forum
Joomla SEF URLs by Artio