K70 - HW Random Number Generator Example

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

K70 - HW Random Number Generator Example

2,599件の閲覧回数
chrisc
Contributor II

Hi,

Is there a code example of how to obtain a seed from the hardware random number generator accelerator on the Kinetis K70 board?  I've found Chapter 37 (Random Number Generator Accelerator) from the following document, but wasn't able to find an example of this being used anywhere.

http://cache.freescale.com/files/microcontrollers/doc/ref_manual/K70P256M150SF3RM.pdf

Thanks,

Chris

ラベル(1)
タグ(4)
0 件の賞賛
返信
1 返信

1,263件の閲覧回数
mjbcswitzerland
Specialist V

Hi Chris

The following code is from the uTasker project:

Initialisation:

POWER_UP(3, SIM_SCGC3_RNGB);     // power up the RNG   

RNG_CR = (RNG_CR_FUFMODE_TE | RNG_CR_AR);   // automatic reseed mode and generate a bus error on FIFO underrun  

RNG_CMD = (RNG_CMD_GS | RNG_CMD_CI | RNG_CMD_CE);    // start the initial seed process // the initial seeding takes some time but we don't wait for it to complete here - if it hasn't completed when we first need a value we will wait for it then

Getting a random number:

  

while (RNG_SR & RNG_SR_BUSY) {}    // wait for the RNG to become ready (it may be seeding)    

while ((RNG_SR & RNG_SR_FIFO_LVL_MASK) == 0) { }  // wait for at least one output word to become available

return RNG_OUT;            // read from the FIFO and return 32 bits of output


Regards

Mark

http://www.uTasker.com