sketch/Entropy.cpp: In member function 'void EntropyClass::initialize()':
Entropy.cpp:62:32: error: 'pmc_enable_periph_clk' was not declared in this scope
pmc_enable_periph_clk(ID_TRNG);
^
On the Arduino MEGA I found no problem.
I tried to install all the board manager versions for Arduino DUE.
I need a (almost) good generator of random bytes (uint8_t) without the need of external hardware, alternatives to this library and other solutions are welcome.
Thanks!
Here is an example sketch to get a 32_bit true random number every us from a DUE:
/************************************************************************************/
/* The True Random Number Generator (TRNG) on the DUE passes the American NIST */
/* Special Publication 800-22 and Diehard Random Tests Suites. */
/************************************************************************************/
#define TRNG_Key (0x524E47)
volatile uint32_t Random;
void setup() {
PMC->PMC_PCER1 |= PMC_PCER1_PID41; // TRNG controller power ON
TRNG->TRNG_CR = TRNG_CR_ENABLE | TRNG_CR_KEY(TRNG_Key);
TRNG->TRNG_IER = TRNG_IER_DATRDY;
NVIC_SetPriority(TRNG_IRQn, 0xFF); // Give TRNG interrupt the lowest urgency (if necessary )
NVIC_EnableIRQ(TRNG_IRQn);
}
void loop() {
// Do something with Random, BUT do not Serial.print every Random
// because any Serial.print takes several hundreds us !
}
/* Fires every 1 us ****/
void TRNG_Handler() {
TRNG->TRNG_ISR; // Clear status register
Random = TRNG->TRNG_ODATA; // Get 32_bit random value
}
I think the Entropy library is doing essentially the same thing. The advantage to using the library is that it also provides random number support for AVR and Teensy, making your code more portable.