> Sorry but which LFSR? The simple LFSR in the PIClist > archive does not seem to do this. > > LFSR: RLF RANDOM,W > RLF RANDOM,W > BTFSC RANDOM,4 > XORLW 1 > BTFSC RANDOM,5 > XORLW 1 > BTFSC RANDOM,3 > XORLW 1 > MOVWF RANDOM > RETLW 0 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. The Jal library contains one: var byte _random_b1 var byte _random_b2 var byte _random_b3 -- make sure there is at least one bit set! asm bsf _random_b1, 0 procedure _random_shift is -- from the art of electronics, p657: -- 24 bits LFSR needs xor feedback from taps at 17, 22 and 23 assembler movlw 0 bank btfsc _random_b3, 1 xorlw 0xFF btfsc _random_b3, 6 xorlw 0xFF btfsc _random_b3, 7 xorlw 0xFF addlw 1 bank rlf _random_b1, f bank rlf _random_b2, f bank rlf _random_b3, f end assembler end procedure Wouter van Ooijen -- ------------------------------------------- Van Ooijen Technische Informatica: www.voti.nl consultancy, development, PICmicro products docent Hogeschool van Utrecht: www.voti.nl/hvu -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist