Jump to content

Recommended Posts

Posted

MIOS32Bit Core LPC17 © >  following Code works:

if(Potentiometer <= (rand() % 255)) {
   Gate = 0;}

What the code does:

The Potentiometer is a Variable > its a Analog Input: Value from 0-255

Gate is a Variable and it Gates a NOTE-STREAM.

All Together its a Note-Random-Killer > with the Pot you set the change to be killed...

 

MIOS 8Bit Core 18F452 © > it DOES NOT work, I got following Error:

p --disable-warning 85 --obanksel=2  -I./src -I ./include/c -I ./include/share -DDEBUG_MODE=0  main.c -o _output/main.o
main.c:224: warning 112: function 'rand' implicit declaration
main.c:224: warning 84: 'auto' variable 'rand' may be used before initialization
main.c:224: warning 84: 'auto' variable 'rand' may be used before initialization
./bin/mios-gpasm modifies _output/main.asm, result in _output/main__mios-gpasm-tmp.asm
_output/main__mios-gpasm-tmp.asm:47:Error [113] Symbol not previously defined (_rand).
_output/main__mios-gpasm-tmp.asm:694:Error [113] Symbol not previously defined (_rand).
_output/main__mios-gpasm-tmp.asm:694:Error [113] Symbol not previously defined (_rand).
make: *** [_output/main.o] Fehler 1


with the MIOS32 bit I dont had to declare nothing...

 

The Quest now:

how to program a random that has a predefinied min:0 & max:255

(I am not a C-Geek, Beginner > Detailed Answer would be great > "comparing 2 Registers in Cycles take the Result and..." > I cant perform such of that into code ;) (leider)

 

(the first workaround and try of building an Analog Noise generator to feed into a AIN with an BC549 failed by smoking en up...)

 

THANKS

Posted

ok got it... the search had results TK: 2006

 

 

   tmp = random_seed_l * random_seed_h;
   random_seed_l = TMR0L + (unsigned char)(tmp & 0xff);
   random_seed_h = 0x69 + (unsigned char)(tmp >> 8);

it makes random numbers from 0 - 255

 

all variables have to defied bevore of course...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...