Created
December 3, 2017 13:10
-
-
Save PaulStoffregen/965c0676ee34bd55b2f6c23e992a0ed3 to your computer and use it in GitHub Desktop.
Quick Entropy library raw data test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A very quick entropy test. Run on Teensy 3.x or Teensy LC. | |
// https://twitter.com/DavidInOregon/status/937304504210423808 | |
volatile uint8_t val=0; | |
volatile bool newval=false; | |
void setup() { | |
SIM_SCGC5 |= SIM_SCGC5_LPTIMER; | |
LPTMR0_CSR = 0b10000100; | |
LPTMR0_PSR = 0b00000101; // PCS=01 : 1 kHz clock | |
LPTMR0_CMR = 0x0006; // smaller number = faster random numbers... | |
LPTMR0_CSR = 0b01000101; | |
NVIC_ENABLE_IRQ(IRQ_LPTMR); | |
} | |
void lptmr_isr(void) | |
{ | |
LPTMR0_CSR = 0b10000100; | |
LPTMR0_CSR = 0b01000101; | |
val = SYST_CVR; | |
newval = true; | |
} | |
void loop() { | |
if (newval) { | |
newval = false; | |
Serial.println(val); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment