Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to generate a random number on AT89C51 ?

Status
Not open for further replies.

buts101

Full Member level 3
Joined
Apr 29, 2005
Messages
168
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Activity points
2,867
Random Number

-->Random Number

I need to generate random number on at89c51 microcontroller i.e. for

the same input(+5) on same pin(P1.1)..i need to make random pin from

P0.0 to P0.7, high. Please help me with the coding either in .asm or

.C

Thank you.
 

Re: Random Number

Use RANDOM Function of C rand() limiting the value between 0 until 7 like it.

#include <stdlib.h>

int t;
t = randon()%8; // Generate a random number between 0 -> 7
then you use ...

P0 |= (1 << t) ; // This set the desired BIT

Where P0 is P0OUT register ... it's just an example because I don't know this processor.

leomecma
 

Re: Random Number

you can test some code using the timer
 

Re: Random Number

hello syrax...
could u post timer coding in C...for getting the same above result (random pin high).
Thank you.
 

Re: Random Number

Hi leomecma
I don't know use C codes in using 8051 microcontroller so how to generate random number using code in asm???
Thank you.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top