cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F207 RNG

Anvi
Associate III

Hello,

I'm having trouble using the RNG peripheral on the STM32F207.

I'm using the HAL functions to set things up and I keep getting back the same number. I've made sure to enable the RNG Clock. See the steps below:

  • Enabled RNG CLK:
__RNG_CLK_ENABLE()
  • Enabled the peripheral:
  __HAL_RNG_ENABLE()
  • Get the random number when available (polling on the ready flag):
HAL_RNG_GetRandomNumber()

The polling doesn't time out, it just keeps returning the same number. I've tried to enable the interrupt as well and the interrupt never arrives.

What am I doing wrong?

Thank you

11 REPLIES 11

Rewrite your code for direct register access, at least the directly RNG related part - that's fairly easy, just enable RNG, and then check status bit and if set, read out data.

You should get a debugger, makes life easier (although sometimes can get into way, too).

JW

Anvi
Associate III

Figured out the problem... I was never setting the Instance of the RNG handler to point to the base of the RNG peripheral so it was never getting enabled. :|

Thanks for all your help.