Random number generation takes too long.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Random number generation takes too long.

Jump to solution
479 Views
liyongfeng
Contributor III

The first execution of random number generation takes 92 ms, whereas the execution time is reduced to dozens of microseconds in all subsequent generations. What causes this difference in execution time?

0 Kudos
Reply
1 Solution
462 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @liyongfeng 

 

This is expected behavior and it is described in HSE Firmware reference manual v2.7, section:

“14.6.12 Delay in processing of first heavy operation after boot”

It’s caused by generation of seed value by true random generator and it cannot be avoided.

Next generations of random number use pseudo random generator which is using that seed. Depending on the RNG class, the reseeding is done periodically as shown in “Table 86. RNG Classes” in the mentioned reference manual.

 

In case of S32K344/324/314, the execution time for seeding depends on HSE clock. It’s about 92ms for 80MHz and about 61ms for 120MHz.

 

In case of other devices, you should see about 40ms mentioned in the manual.

 

Regards,

Lukas

View solution in original post

0 Kudos
Reply
1 Reply
463 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @liyongfeng 

 

This is expected behavior and it is described in HSE Firmware reference manual v2.7, section:

“14.6.12 Delay in processing of first heavy operation after boot”

It’s caused by generation of seed value by true random generator and it cannot be avoided.

Next generations of random number use pseudo random generator which is using that seed. Depending on the RNG class, the reseeding is done periodically as shown in “Table 86. RNG Classes” in the mentioned reference manual.

 

In case of S32K344/324/314, the execution time for seeding depends on HSE clock. It’s about 92ms for 80MHz and about 61ms for 120MHz.

 

In case of other devices, you should see about 40ms mentioned in the manual.

 

Regards,

Lukas

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2342732%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERandom%20number%20generation%20takes%20too%20long.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2342732%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThe%20first%20execution%20of%20random%20number%20generation%20takes%2092%20ms%2C%20whereas%20the%20execution%20time%20is%20reduced%20to%20dozens%20of%20microseconds%20in%20all%20subsequent%20generations.%20What%20causes%20this%20difference%20in%20execution%20time%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2343094%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Random%20number%20generation%20takes%20too%20long.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2343094%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F184101%22%20target%3D%22_blank%22%3E%40liyongfeng%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThis%20is%20expected%20behavior%20and%20it%20is%20described%20in%20HSE%20Firmware%20reference%20manual%20v2.7%2C%20section%3A%3C%2FP%3E%0A%3CP%3E%E2%80%9C14.6.12%20Delay%20in%20processing%20of%20first%20heavy%20operation%20after%20boot%E2%80%9D%3C%2FP%3E%0A%3CP%3EIt%E2%80%99s%20caused%20by%20generation%20of%20seed%20value%20by%20true%20random%20generator%20and%20it%20cannot%20be%20avoided.%3C%2FP%3E%0A%3CP%3ENext%20generations%20of%20random%20number%20use%20pseudo%20random%20generator%20which%20is%20using%20that%20seed.%20Depending%20on%20the%20RNG%20class%2C%20the%20reseeding%20is%20done%20periodically%20as%20shown%20in%20%E2%80%9CTable%2086.%E2%80%87RNG%20Classes%E2%80%9D%20in%20the%20mentioned%20reference%20manual.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EIn%20case%20of%20S32K344%2F324%2F314%2C%20the%20execution%20time%20for%20seeding%20depends%20on%20HSE%20clock.%20It%E2%80%99s%20about%2092ms%20for%2080MHz%20and%20about%2061ms%20for%20120MHz.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EIn%20case%20of%20other%20devices%2C%20you%20should%20see%20about%2040ms%20mentioned%20in%20the%20manual.%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3ERegards%2C%3C%2FP%3E%0A%3CP%3ELukas%3C%2FP%3E%3C%2FLINGO-BODY%3E