Problem
Using the AVR Studio simulator.
Write an assembly program for the Atmega 8535 AVR Microcontroller, that generates a random set of lottery numbers.
Your system should generate six, two-digit numbers, between 01 to 59.
For each two-digit number, the most significant digit should be displayed on Port A in binary, the least significant bit should be displayed on Port B.
Development
Program code should be structured using subroutines and must contain sufficient comments to annotate the code’s behaviour.
The system should be developed and tested incrementally. i.e., add one feature at a time, test it, before moving on.
Pseudo Random Number Algorithm
If you start with a pre-seeded number, something other than zero, you can use the XOR and shift method to create a random-number generator.
When done correctly, you will have a sequence that does not repeat for (2n – 1) times, where n is the number of bits you are shifting.
It works like this. Start with a number, for example the hex number $66, 0110 0110 in binary.
Take the bottom two bits and XOR them together, then take that result and shift it onto the most significant bit of the number.
If you continue this method, you achieve a sense of randomness. First number and successive numbers: – 66, B3, 59, AC etc.