Sorry but I think 3 bit of random number is not the same as 0-7 and 5 bit of random number is not the same as 0-31. Do I miss something obvious? Regards, Xiaofan -----Original Message----- From: David P Harris [mailto:dpharris@telus.net] Sent: Thursday, June 23, 2005 5:38 PM To: Microcontroller discussion list - Public. Subject: Re: [PIC] Simple pseudo random code generation >Sorry but which LFSR? The simple LFSR in the PIClist >archive does not seem to do this. > Yes it does. You shift the random number to the left. Then you XOR the first bit depending on the other bits. So only the first bit gets changed. You will need to run through 3 times for 0-7, and 5 times for 0-31. David -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist