Merge pull request #82 from ea/rngfix

Addressing #67 - RNG now has more uniform distribution
This commit is contained in:
Travis Goodspeed 2018-04-04 11:00:32 -04:00 committed by GitHub
commit 4208632926
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,8 +43,10 @@ unsigned int true_rand(void) {
seed <<= 1;
if (ones >= 3) //majority of 5 samples
seed |= 1;
UCSCTL1 += 5; // update DCORSEL to change speed
UCSCTL5 ^= ((seed & 3) << 8); // update ALCK divider
// even though SLA338 recomends changing dividers and speed to increase
// uniformity, tests have shown better results with these two lines disabled
//UCSCTL1 += 5; // update DCORSEL to change speed
//UCSCTL5 ^= ((seed & 3) << 8); // update ALCK divider
}
// restore everything we've been messing with