In this use case, the True Random Number Generator (TRNG) module is configured for:
- The TRNG peripheral will not be stopped in standby sleep mode
This use case will read random data in polling mode repeatedly. After reading a data, the board LED will be toggled.
Setup
Prerequisites
There are no special setup requirements for this use-case.
Code
Copy-paste the following setup code to your user application:
Add to user application initialization (typically the start of main()
):
Workflow
- Create a TRNG device instance struct, which will be associated with a TRNG peripheral hardware instance.
- Note
- Device instance structures shall never go out of scope when in use.
- Create a new function
configure_trng()
, which will be used to configure the overall TRNG peripheral.
- Create a TRNG peripheral configuration structure that will be filled out to set the module configuration.
- Fill the TRNG peripheral configuration structure with the default module configuration values.
- Initialize the TRNG peripheral and associate it with the software instance structure that was defined previously.
- Enable the now initialized TRNG peripheral.
Implementation
Code
Copy-paste the following code to your user application:
uint32_t random_result;
while (true) {
}
volatile uint32_t delay = 50000;
while(delay--) {
}
}
Workflow
- Make the application loop infinitely.
- Start to read a random data from TRNG until success.
- Toggle the board LED to indicate a random data is read.
volatile uint32_t delay = 50000;
while(delay--) {
}