The prescaler is at maximum but the clock is 20MHz. I will include a loop
to give a new number if the number chosen was the same as the last which
should help as only an even distribution of nos is needed and not a true
random. The code looks good. Mine got the timer value and counted
subtractions of a number and the code was huge. Is it the timer which is
skewed or the way the code is implemented?
Thanks
Tim
{Quote hidden}>Tim:
>
>To select a TMR0-based number between 1 and 12, inclusive, do
>something like this:
>
> LOOP: MOVF TMR0,W
> ANDLW 00001111B
> ADDLW -12
> BC LOOP
> ADDLW 13
>
>After executing the fragment above, W will contain a number in the
>range [1-12]. This is just about the worst possible way to get
>random numbers -- the distribution is VERY skewed toward the low end
>of the range, and the whole thing's based on a deterministic timer --
>but it's quick (so long as you haven't enabled a large TMR0
>prescaler), easy, and doesn't require any additional file registers.
>
>-Andy
>
>=== Andrew Warren -
fastfwd
KILLspamix.netcom.com ===
>=== Fast Forward Engineering - Vista, California ===
>=== ===
>=== Did the information in this post help you? Consider ===
>=== contributing to the PICLIST Fund. Details are at: ===
>===
http://www.geocities.com/SiliconValley/2499/fund.html ===
>