Hello together.
I would like to write a program that give me a random number (range: no matter). I can't realize it. I use PIC controllers, may that could help you to give me an answer. Program languages are C or BASIC.
Please help me. Thank a lot!!
Hello together.
I would like to write a program that give me a random number (range: no matter). I can't realize it. I use PIC controllers, may that could help you to give me an answer. Program languages are C or BASIC.
Please help me. Thank a lot!!
Hi Christian
Closet to a Pseudo Random Number Generator that I know of is the following white noise generator code that I have used
Registers required
Lobyte
Midbyte
Hibyte
Code
movlw 0x0A
movwf Lobyte
movwf Midbyte
movwf Hibyte
Loop
rlf Lobyte,f
rlf Midbyte,f
rlf Hibyte,f
movlw 0xA1
btfsc STATUS,C
xorwf Lobyte,f
movfw Hibyte
movwf GPIO ;For demonstration purposes White Noise will be on GPIO,0
goto Loop
Regards
Graham
Works well for white noise, and a generated random number on any of the bytes
Hi Christian
Closet to a Pseudo Random Number Generator that I know of is the following white noise generator code that I have used
Registers required
Lobyte
Midbyte
Hibyte
Code
movlw 0x0A
movwf Lobyte
movwf Midbyte
movwf Hibyte
Loop
rlf Lobyte,f
rlf Midbyte,f
rlf Hibyte,f
movlw 0xA1
btfsc STATUS,C
xorwf Lobyte,f
movfw Hibyte
movwf GPIO ;For demonstration purposes White Noise will be on GPIO,0
goto Loop
Regards
Graham
Works well for white noise, and a generated random number on any of the bytes