Random and pseudorandom number generation for the MSP430, implemented in C.
msp430-elf-gcc -o foo.elf foo.o rand.o
Truly random number generator. Uses the time difference between the VLO and DCO, as outlined in SLAA338. It is self-contained, but it mucks about with clocks and timers, so it is only intended to be used very early on to generate the seed for a PRNG.
A very simple and fast PRNG implemented by a linear congruential generator with the following values:
- modulus: 65536 (2^16)
- multiplier: 49381
- increment: 8643
To run the tests,
make test and run
test.elf on your MSP430.
They should take less than a minute to finish.
The test mechanism assumes that you are using a Launchpad, with LEDs on pins 0 and 6. While the tests are running, both LEDs are on; when the tests finish, one of the LEDs blinks (green: pass, red: fail).
Using mspdebug, it is easy to see which test is failing and possibly why:
prog test.elf run ^C md status 2 md sum_rand 2 md sum_prand 2
An implementation of the Monobit algorithm outlined in section 2.1 of SP 800-22 Rev. 1a. Checks that the numbers of 0 and 1 bits in the produced values are equal to within a certain tolerance.
Provided under the terms of the MIT license. See LICENSE.txt for more information.