Hi Team,
Is there any problem if call myCOM_generateRandomBytes() every second in software? A customer needed to get random number every second and the program crashed [UART crashed too]. And this problem did not appear when online emulating, but easily occurred when single chip running.
Please check his code below:
/* Generate random bytes in the provided buffer up to size using the TRNG */ void myCOM_generateRandomBytes(void) { int_fast16_t result; // if (canTrigTrng) // { // return; // } // canTrigTrng = true; /* Generate some randomness in the provided buffer */ // if (handleTrng) { result = TRNG_generateEntropy(handleTrng, &entropyKey); if (result != TRNG_STATUS_SUCCESS) { TRNG_close(handleTrng); handleTrng = TRNG_open(Board_TRNG0, ¶mTrng); if (!handleTrng) { while (1) ; } } } // TRNG_close(handleTrng); } void init_generateRandom(uint8_t size) { TRNG_init(); CryptoKeyPlaintext_initBlankKey(&entropyKey, keyLocationBuffer, size); TRNG_Params_init(¶mTrng); paramTrng.returnBehavior = TRNG_RETURN_BEHAVIOR_CALLBACK; paramTrng.callbackFxn = trng_callback; paramTrng.timeout = SemaphoreP_WAIT_FOREVER; /* Open a TRNG_Handle with default parameters */ handleTrng = TRNG_open(Board_TRNG0, ¶mTrng); if (!handleTrng) { while (1) ; } myCOM_generateRandomBytes(); }
BR,
Viki Shi