Random seed in 'mega32

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys,

I was wondering what you recommend for a random seed in an atmega32. Would it make sense to start a timer and have it until a watchdog interrupt occurs?

My project uses an external crystal. I'd prefer to not use eeprom and update the seed. Ideally, the random seed should come from something internal to the MCU, either an asynchronous timer or a memory which defaults go mumbo-jumbo.

The application is a bootloader which will only start the main application N times before it requests an enable code. The counter value is to reside in protected application memory. To enable the device, random hex characters are written to a display and the user needs to enter a sequence of bits derived from them.

I'll be more than happy to open source the code that does this :-)

Thanks,
Borge

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One technique is to use the LSB of 8 or 16 ADC reads. If the ADC channel is high-impedance, that's best (even just an open pin on an unused channel).

Another is to start a fast-running timer and capture its value when you receive your first outside input (UART char, keypress, etc).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks. I had those in mind too, just hoping to avoid external circuitry or user interaction. I see now that the mega32 has no watchdog interrupt. I must have confused it with a mega48 project I did some time ago.

In my application all the ADC pins (PA0-7) are used to interface an LCD module. They are all outputs. I'll see if I'm able to get any randomness out of that by temporarily turning them into inputs.

Borge

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want something like a mega32 with a WDT interrupt look at the mega324 perhaps?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have so much code written for the '16 and '32, plus my layout is already done.

What do you think about using the same ADC pin for both sides of a differential conversion, and use an internal gain of 200? Then any randomness should be due to internal noise and not somebody tampering with the random seed generator. I'll try to code it up and see if there is any randomness in there.

Borge