Pages: [1]   Go Down
Author Topic: Access All 16 Analog Channels  (Read 1286 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 2
Posts: 68
Good Vibes, Bad Vibes, Random Vibe
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


The Arduino Due features 12 analog ADC, however the AT91SAM3X8E chip has 16 analog pins. 

Is it possible to access the 4 omitted ADCs from the Due headers and program them in the IDE?  Thank you.
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8589
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In typical Atmel marketing-BS the SAM only has 15 usable ADC inputs because the 16th is dedicated to the internal temp sensor.

AD0:7 and AD10:13 are the official analogue inputs.

Here is a list of the non-official ADC inputs

AD8 - PB12 - SDA - D20
AD9 - PB13 - SCL - D21
AD14 - PB21 - D52
AD15 - internal temp

So you can get access to them (except AD15) but bear in mind that D20 and D21 have pullup resistors for the I2C.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Offline Offline
Jr. Member
**
Karma: 2
Posts: 68
Good Vibes, Bad Vibes, Random Vibe
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the response.

Are the I2C pull-ups on the Due board or the chip?  If on the chip, can they be disabled to make a proper ADC channel?
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8589
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The resistors are on the board, you would have to physically remove them. Alternatively drive the inputs with a low-impedance source like an opamp, I doubt that would be affected by the 1k5 resistor.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13846
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
AD15 - internal temp

So you can get access to them (except AD15) but bear in mind that D20 and D21 have pullup resistors for the I2C.

That AD15, can it be used to collect entropy to seed the random generator?

investigated something similar for the UNO long ago - http://forum.arduino.cc/index.php/topic,38091.0.html - but it was not noisy enough. Maybe the Due is?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Chicago, IL. USA
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know if this helps, but the Due's processor has a "True Random Number Generator" built into it.  Chapter 43 of the SAM3X manual discusses it: http://www.atmel.com/Images/doc11057.pdf.  I'm not really knowledgable about how good the various randomness specs are, but the manual claims the SAM3X's generator passes the NIST Special Publication 800-22 and the Diehard Random test suites.

I stumbled across that chapter while reading about the timer counters and USARTs in the microcontroller.

- Madeline
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 220
Posts: 13846
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Madeline,

Didn't find time to read much about the Due so I'm a noob on that board/processor.

The control register has a 24 bit key - do you know if it works as a seed?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Chicago, IL. USA
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

[...] The control register has a 24 bit key - do you know if it works as a seed?

That key is actually just for write-protecting the register.  Many of the SAM3X8E's built-in peripherals require a security key (to protect against run-away code overwriting the registers?).  With the Timer Counters, for example, one of the peripheral's registers is the Write Protect Mode Register.  You need to write the security key to that register before you can write to most of the other registers in that peripheral. 

The True Random Number Generator has so few registers that, rather than having a separate one for controlling the write-protection, they combined the security key and the bit for enabling the TRNG in the Control Register.  For the TRNG, the key is always 0x524E47 (which is "RNG" if viewed as ASCII characters).  So, to enable the TRNG you write 0x524E4701 to that register, and to disable it, you write 0x524E4700.

Hope that helps!

- Madeline
Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

[...] The control register has a 24 bit key - do you know if it works as a seed?

That key is actually just for write-protecting the register.  Many of the SAM3X8E's built-in peripherals require a security key (to protect against run-away code overwriting the registers?).  With the Timer Counters, for example, one of the peripheral's registers is the Write Protect Mode Register.  You need to write the security key to that register before you can write to most of the other registers in that peripheral. 

The True Random Number Generator has so few registers that, rather than having a separate one for controlling the write-protection, they combined the security key and the bit for enabling the TRNG in the Control Register.  For the TRNG, the key is always 0x524E47 (which is "RNG" if viewed as ASCII characters).  So, to enable the TRNG you write 0x524E4701 to that register, and to disable it, you write 0x524E4700.

Hope that helps!

- Madeline


To generate TNRG you can use this: is somewhere from this forum I can't remeber at this time.
Code:
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(trueRandom());
  delay(500);
}

uint32_t trueRandom() {
    static bool enabled = false;
    if (!enabled) {
        pmc_enable_periph_clk(ID_TRNG);
        TRNG->TRNG_IDR = TRNG_IDR_DATRDY;
        TRNG->TRNG_CR = TRNG_CR_KEY(0x524e47) | TRNG_CR_ENABLE;
        enabled = true;
    }

    while (! (TRNG->TRNG_ISR & TRNG_ISR_DATRDY));
    return TRNG->TRNG_ODATA;
}
Logged

Pages: [1]   Go Up
Jump to: