We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Does anybody know how to generate random number using 8051?
As you just want numbers 0..127, why not just use a lookup table - so each "call" to rand() just returns the next entry?
As you just want numbers 0..127, why not just use a lookup table - so each "call" to rand() just returns the next entry? But, Ivan said that he was out of code memory. Ivan: if you are really desparate for space, it would be possible to implement an 8 or 7 bit LFSR. The advantage of a 7-bit LFSR is that it would give you values in the range 1..127 without any further processing. On the other hand the sequence would not be very random - you will get all the values 1..127 exactly once before the sequence repeats. If that is what you want, I can probably write a generator in about five minutes!