
True Random Number Generator (RNG)
RM0351
812/1830
DocID024597 Rev 5
Caution:
When the CEC bit in the RNG_CR register is set to “1”, the RNG clock frequency
must be
higher
than AHB clock frequency divided by 16, otherwise the clock checker will flag a clock
error (CECS or CEIS in the RNG_SR register) and the RNG will stop producing random
numbers.
See
Section 27.3.1: RNG block diagram
for details (AHB and RNG clock domains).
27.3.7 Error
management
In parallel to random number generation an health check block verifies the correct noise
source behavior and the frequency of the RNG source clock as detailed in this section.
Associated error state is also described.
Clock error detection
If the RNG clock frequency is too low, the RNG stops generating random numbers and sets
to “1” both the
CEIS
and
CECS
bits to indicate that a clock error occurred. In this case, the
application should check that the RNG clock is configured correctly (see
) and then it must clear the CEIS bit interrupt flag. As soon as the RNG clock
operates correctly, the CECS bit will be automatically cleared.
The RNG operates only when the CECS flag is set to “0”. However note that the clock error
has no impact on the previously generated random numbers, and the RNG_DR register
contents can still be used.
Noise source error detection
When a noise source (or seed) error occurs, the RNG stops generating random numbers
and sets to “1” both
SEIS
and
SECS
bits to indicate that a seed error occurred. If a value is
available in the RNG_DR register, it must not be used as it may not have enough entropy.
In order to fully recover from a seed error application must clear the SEIS bit by writing it to
“0”, then clear and set the RNGEN bit to reinitialize and restart the RNG.
27.4
RNG low-power usage
If power consumption is a concern, the RNG can be disabled as soon as the DRDY bit is set
to “1” by setting the RNGEN bit to “0” in the RNG_CR register. The 32-bit random value
stored in the RNG_DR register will be still be available. If a new random is needed the
application will need to re-enable the RNG and wait for 42+4 RNG clock cycles.
When disabling the RNG the user deactivates all the analog seed generators, whose power
consumption is given in the datasheet electrical characteristics section.
27.5 RNG
interrupts
In the RNG an interrupt can be produced on the following events:
•
Data ready flag
•
Seed error, see
Section 27.3.7: Error management
•
Clock error, see
Section 27.3.7: Error management
Dedicated interrupt enable control bits are available as shown in