Register now for the most anticipated Asia Pacific Power Seminar 2022

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

USB superspeed peripherals Forum Discussions

Not applicable

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 (, 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,



3 Replies
Not applicable

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.

Level 2
Level 2

 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 .

Not applicable



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