There is a ASM code for Random I've found on the micrchip website
If the other methods do not work, I'll try to include this ASM on my PBP code.
I'll let you know.
;Random Number Generator
;
; This routine generates a 16 Bit Pseudo Sequence Random Generator
; It is based on Linear shift register feedback. The sequence
; is generated by (Q15 xorwf Q14 xorwf Q12 xorwf Q3 )
;
; The 16 bit random number is in location RandHi(high byte)
; & RandLo (low byte)
;
; Before calling this routine, make sure the initial values
; of RandHi & RandLo are NOT ZERO
; A good chiose of initial random number is 0x3045
;************************************************* ******************
;
Random16
rlcf RandHi,W
xorwf RandHi,W
rlcf WREG, F ; carry bit = xorwf(Q15,14)
;
swapf RandHi, F
swapf RandLo,W
rlncf WREG, F
xorwf RandHi,W ; LSB = xorwf(Q12,Q3)
swapf RandHi, F
andlw 0x01
rlcf RandLo, F
xorwf RandLo, F
rlcf RandHi, F
return




Bookmarks