Alkex Posted September 13, 2006 Report Posted September 13, 2006 Hi all,I am working on a funky 14x10 dot matrix display for my next midibox and would like to program a random pattern animation.I am using a matrix of 14 anodes X 10 cathodes and would like to set the anodes high randomly at each Cathode shift, so I need a 1-14 random integer, but can't work the SEQ_CORE_GenRandomNumber...I would greatly appreciate it if someone could guide me through this fonction ...thanks in advance!Best regardsAlkex Quote
TK. Posted September 14, 2006 Report Posted September 14, 2006 Hi Alkex,the usage of this function is very easy - each time you are calling it, a new random number will be put into SEQ_RANDOM_SEED_L and SEQ_RANDOM_SEED_H - you can extract a bit or a bitfield from these registers like you want. E.g., if you need a 7bit value, write: SET_BSR SEQ_BASE movf SEQ_RANDOM_SEED_L, W, BANKED andlw 0x7f ; masks 7bit from the low-byte[/code] In MBSEQ V3, I've optimized the function in following way: [code];; --------------------------------------------------------------------------;; This function generates a new random number;; OUT: new random number in SEQ_RANDOM_SEED_[LH];; --------------------------------------------------------------------------SEQ_CORE_GenRandomNumber SET_BSR SEQ_BASE movf SEQ_RANDOM_SEED_L, W, BANKED mulwf SEQ_RANDOM_SEED_H, BANKED movf TMR0L, W addwf PRODL, W movwf SEQ_RANDOM_SEED_L, BANKED movlw 0x69 addwfc TMR1L, W addwfc PRODH, W movwf SEQ_RANDOM_SEED_H, BANKED returnby using the values of two different timers, the randomness is higherBest Regards, Thorsten. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.