It is not a bug. Computer systems of all types are, at their core, logic devices - incapable of random or chaotic operation. More complex systems simulate randomness by "seeding" their random generator with, perhaps, the bit-sum of some area of uninitialized memory or an algorithm based on the time and date. In this way they start the "random" sequence at an unknowable (but calculated) location - this gives the appearance of randomness, but is not.
On such a simple system as the PIC, this "seeding" is left to the designer. You might, for example, loop from 0 to the current value of Timer1 before selecting your "random" value - unlikely "rolls" will be so perfectly timed as to make the outcome calculable.




Bookmarks