/*############################################################# Program Name : ex1_rng_GenerateRandomNumbers Author : Grant Phillips Date Modified : 08/02/2016 Compiler : ARMmbed Tested On : STM32F4-Discovery Description : A program to demonstrate the use of the true Random Number Generator (RNG) on STM32F4xxx devices through the use of the STM32F_RNG class library. This example will simply display the 32-bit random generated numbers. Requirements : * STM32F4-Discovery Board Circuit : * A wire link between PB3 and pin6 of the SWD connector (CN2) as explained in the SWV examples section ##############################################################*/ #include "mbed.h" #include "STM32F4_RNG.h" #include "SWO.h" STM32F4_RNG rnd; //create a STM32F4_RNG object SWO_Channel SWO; int main() { // create a 32-bit unsigned variable unsigned long num; //or uint32_t num while(1) { num = rnd.Get(); //get the next 32-bit random number and store in num SWO.printf("%u\n", num); //display the unsigned (%u) 32-bit number wait(1.0); } }