3 Replies Latest reply on Mar 5, 2013 4:16 AM by RaN_283461

    Random numbers

      Hi there,




      is there a way to generate random numbers by facilities on the ARM9? I don't want to use the libc rand()/srand() but would rather resort to the processors native RNG, which does exist in the NXP MCU product (http://www.nxp.com/documents/data_sheet/LPC3130_31.pdf), so it might as well be present in the FX3.




      If it is, is there an easy way to use it? If not, is there any other recommended way to generate a decent amount of entropy (about 4k at a shot)?




      Thanks in advance,



        • 1. Re: Random numbers

          Hi Markus,




          We do not have a random generator on the FX3 silicon. The only hardware option is to set up a GPIO timer with a low period (period = range of values to be generated) and sample it to get the random number.




          The CyU3PGpioSetComplexConfig function can be used as follows to set up the timer:




          CyU3PGpioComplexConfig_t gpioConf = {


                          CyFalse, CyFalse, CyFalse, CyFalse,


                          CY_U3P_GPIO_MODE_STATIC,                 /* The GPIO itself is not to be affected, we just use the timer. */


                          CY_U3P_GPIO_NO_INTR,                            /* No interrupts associated with this timer. */


                          CY_U3P_GPIO_TIMER_HIGH_FREQ,       /* Run the GPIO at the high clock frequency selected at GpioInit. */


                          0,                                                                            /* Start timer at 0. */


                          RANDOM_MAX,                                              /* Set the period to the range of the numbers to be generated. */


                          0                                                                              /* The threshold is don't care. */




          CyU3PGpioSetComplexConfig (0, &gpioConf);




          The CyU3PGpioComplexSampleNow function can then be used to get the current timer value to serve as a random number.




          Please note that the RANDOM_MAX needs to be set to a low value to be able to get good entropy.






          Sai Krishna.

          • 2. Re: Random numbers

             I think you can also use the api CyU3PGetTime to get the system time. I do some operation on it to get a random number .

            • 3. Re: Random numbers



              who  can tell me how to convert the number of tick from CyU3PGpioComplexSampleNow  to time