Tool/software:
The following initialization code doesn't work, but if increase TRNG_POST_TEST_CMD_DELAY to 520, it will work (return true).
However, if use following code piece, and later use CCS to attach debugger upon it hangs to while(1) and check the register TRNG->TEST_RESULTS, the result is 0xFF (pass).
Can you provide a way to check if digital test has done?
MCLK=32MHz
//See mspm0g1507 datasheet 7.23.2 #define TRNG_STARTUP_DELAY_US 520 //Weird, why do we need this #define TRNG_POST_TEST_CMD_DELAY 400 static bool rng_init(void) { DL_TRNG_reset(TRNG); DL_TRNG_enablePower(TRNG); hal_delay_us(TRNG_STARTUP_DELAY_US); DL_TRNG_setClockDivider(TRNG, DL_TRNG_CLOCK_DIVIDE_2); //Make sure in 9.6MHz - 20MHz range DL_TRNG_sendCommand(TRNG, DL_TRNG_CMD_NORM_FUNC); while (!DL_TRNG_isCommandDone(TRNG)); DL_TRNG_sendCommand(TRNG, DL_TRNG_CMD_TEST_DIG); while (!DL_TRNG_isCommandDone(TRNG)); hal_delay_us(TRNG_POST_TEST_CMD_DELAY); if (DL_TRNG_DIGITAL_HEALTH_TEST_SUCCESS != DL_TRNG_getDigitalHealthTestResults(TRNG)) { ////////code fall to here. // set_led_operation(LED_AMBER, LED_OP_ON); while(1); return false; } DL_TRNG_sendCommand(TRNG, DL_TRNG_CMD_TEST_ANA); while (!DL_TRNG_isCommandDone(TRNG)); hal_delay_us(TRNG_POST_TEST_CMD_DELAY); if (DL_TRNG_ANALOG_HEALTH_TEST_SUCCESS != DL_TRNG_getAnalogHealthTestResults(TRNG)) { // set_led_operation(LED_GREEN, LED_OP_ON); while(1); return false; } DL_TRNG_sendCommand(TRNG, DL_TRNG_CMD_NORM_FUNC); while (!DL_TRNG_isCommandDone(TRNG)); DL_TRNG_clearInterruptStatus(TRNG, DL_TRNG_INTERRUPT_CMD_DONE_EVENT); DL_TRNG_setDecimationRate(TRNG, DL_TRNG_DECIMATION_RATE_8); DL_TRNG_clearInterruptStatus(TRNG, (DL_TRNG_INTERRUPT_CAPTURE_RDY_EVENT)); // DL_TRNG_enableInterrupt(TRNG, (DL_TRNG_INTERRUPT_CAPTURE_RDY_EVENT)); //Discard the 1st output while (!DL_TRNG_isCaptureReady(TRNG)); DL_TRNG_getCapture(TRNG); return true; }