This second random app uses the Random Number Generator to output true random noise to the onboard Dac @ the maximum operating bitrate of 1.2 Mbps.
At a clock rate of 1.2 Mhz, the Systick counter rolls over and generates an interrupt. Using the WFI (Wait For Interrupt) instruction we set the F4 to sleep and just wait.
When awoken by the Systick Interrupt the F4 enables both Dac software triggers @ DAC_SWTRIGR. Then we check the state of both of the error flags
CEIS & SEIS @ RNG_SR. If either of these flags is set, then we clear the flags in the status register and the DRDY flag in register RNG_CR.
If neither of the error flags were set, then the state of the DRDY flag in register RNG_CR is examined, and if it is set, the next three instructions in sequence are
carried out. If not the app loops back to the label Loop. I n this way, the true random noise is continually sent out to the Dual Dac.
In Start we firstly initialise the pointer in register R2 and the constants in registers R3, R5 , R6. Next we setup the Systick interrupt to overflow @ 1.2 Mhz.
Thereafter we enable the GPIOA in register RCC_AHB1ENR. GPIOA pins 5 & 4 are then both initialised as Analog Mode Inputs. Although both of these pins are
allocated as the two Dac Digital Outputs, it seems we first have to initialise them thus! Please check page 250 in the RM0090 Reference Manual for more info.
" Once the DAC channelx is enabled, the corresponding GPIO pin (PA4 or PA5) is automatically connected to the analog converter output (DAC_OUTx).
In order to avoid parasitic consumption, the PA4 or PA5 pin should first be configured to analog (AIN)."
We reset and clear the Random Number Generator module @RCC_AHB2RSTR , and then enable the clock for the Random Number Generator > @RCC_AHB2ENR.
Then the DAC interface clock is enabled @RCC_APB1ENR. Thereafter we can reset and clear the DAC interface module @RCC_APB1ENR. And lastly the following
parameters can be selected @DAC_CR: Software Trigger, Ten1, Ten2, Boff1, Boff2, En1, En2. Using a dual beam oscilloscope of minimum 10 Mhz bandwidth, one
can observe the hidden world of pure randomness in action. Exercise caution though! What you perceive as "structure" on the scope is often what you project ;-)
" I got a pretty good education, and it took me years to get over it!" Tony de Mello.