![Texas Instruments CC2533 Скачать руководство пользователя страница 330](http://html.mh-extra.com/html/texas-instruments/cc2533/cc2533_user-manual_1094592330.webp)
Random Number Generation
When receiving CMD_DEMOD_TEST, the LLE starts the receiver, but does not start sync search. The
receiver runs until a CMD_SHUTDOWN command (or a command starting another task) is sent.
When receiving CMD_RX_TEST, the LLE starts the receiver and starts sync search. Any received data is
discarded. The receiver runs until a CMD_SHUTDOWN command (or a command starting another task) is
sent.
When receiving a CMD_TX_TEST, the LLE starts the transmitter and starts sending all zeros. The Tx test
command is normally combined with configuration of the modem to send a tone or by the BSP to send a
whitening sequence. The transmitter runs until a CMD_SHUTDOWN command (or a command starting
another task) is sent. In order to send random modulated data for test purposes, it is recommended to set
BSP_MODE
to 0x03 to enable both whiteners.
In order to send a continuous wave (CW),
MDMCTRL0.TX_IF
can be set to 1 before the CMD_TX_TEST
command is issued. In this case, the radio outputs a tone with the frequency given in
MDMTEST1.TX_TONE
. In most cases, a tone at the synthesizer frequency is wanted (e.g., to measure
phase noise), in which case
MDMTEST.TX_TONE
should be set to 0x0A. The frequency synthesizer must
be programmed to the carrier frequency with no offset in this case; see
When receiving a CMD_TX_FIFO_TEST, the LLE starts the transmitter and starts sending from the Tx
FIFO; otherwise, the command is as CMD_TX_TEST. The MCU must feed data into the Tx FIFO to avoid
underflow, and the Tx FIFO must be set up with auto commit and auto deallocate.
When receiving a CMD_PING command, the LLE responds with a
PINGRSP
. This can be used for
checking that the LLE code is running.
25.10 Random Number Generation
The CC2541 has a hardware pseudo-random register, as explained in
. The RF core register
bank provides a second interface to this register. Reading the
RFPSRND
register is equivalent to reading
RNDL
, then writing 01 to
ADCCON1.RCTL
.
For seeding the pseudo-random number generator and for tasks where higher entropy of the random
numbers is needed, the radio can be used as a true-random generator. The register
RFRND
provides
access to the least-significant bits of the radio ADC, which is random when noise is received. In order to
get values on this register, the receiver must be turned on. The value in
RFRND
is updated every 0.17
µ
s,
so the sampling of that register must be slower than that in order to get a new value with every sample.
To get true random numbers, the following procedure can be followed:
1. Program
FREQCTRL
to a channel that is not likely to contain a narrow-band signal. A frequency outside
the ISM band, such as a setting of 0, is recommended.
2. Program
LNAGAIN
to 0 to have minimum reception of a signal on the air.
3. Start the receiver in test mode by issuing a CMD_DEMOD_TEST command.
4. Wait until ADC data are ready. This can be seen by the
RFRND
register having a value different from 0.
5. Read the number of values needed from
RFRND
. Make sure that there is at least 0.17
µ
s between each
read (i.e., at least 6 cycles if running on 32 MHz). For instance, to seed the pseudo-random generator,
two values are needed.
6. Shut down the receiver by issuing a CMD_SHUTDOWN command
The values read from the
RFRND
register do not have a perfectly uniform distribution. In order to improve
this, several random numbers can be combined to produce one random number. One way of doing this is
to use the pseudo-random generator in CRC mode and combine 8 numbers into one. An example of how
this can be done is given in the C code below:
// Store LNA gain setting and set minimum LNA gain
lnagain_stored = LNAGAIN;
LNAGAIN = 0x00;
// Set lowest possible frequency to avoid signals in ISM band
FREQCTRL = 0x00;
// Enable radio in Rx without sync search
while (RFST != 0);
330
CC2541 Proprietary Mode Radio
SWRU191C
–
April 2009
–
Revised January 2012
Copyright
©
2009
–
2012, Texas Instruments Incorporated