Tim Kerby wrote: > I am about to reach a deadline on a project at school (for the > engineering scheme scotland) and my random no generation isnt > working. It must take the tmr0 or any internal part of the chip as > i dont have lines to spare and give out a number between 1 and 12 > (inclusive). 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@ix.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 ===