Thanks a lot for the explanation. The problem is that I can not afford to call the routine 8 times: I can only afford to call the routine at most two times. I am doing this on a 12F629 with 4MHz internal oscillator (1us per instruction) and my normal loop time can not exceed 125us (with a filter depth of 8, which lead to 1ms response time for the program). The fixed loop time is about 70us and I want to generate a delay of 24-52us (20us overhead + 4-32 us of delay) leading to a loop time of 94-122us ( average 108us). So I have very limited time to do this. Regards, Xiaofan -----Original Message----- From: Wouter van Ooijen [mailto:wouter@voti.nl] Sent: Thursday, June 23, 2005 7:25 PM To: 'Microcontroller discussion list - Public.' Subject: RE: [PIC] Simple pseudo random code generation It does. Each time you call this routine it shifts the (in this case 16-bit) value on step and generates one new pseudo-random bit, which is inserted into the just vacated bit. If you want it to generate for instance a random byte you must call it 8 times, otherwise there will be a very strong correlation between successive bytes. OMHO 16 bit is often a bit short, I would opt for a 24-bit SR. ... -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist