Here's the function I use. It need some kind of initiating function - I use an internal clock function called readRTC(), but you probably have a clock function you can access ...

/* infamous 0xDEADBEEF pseudo-random number generator by

Robbert Haarman

http://inglorion.net returns number between 0x0000 and 0xFFFF */

int rand() {

static int deadbeef_seed, deadbeef_beef;

if (deadbeef_beef == 0xdeadbeef) // initialize

deadbeef_seed = readRTC();

deadbeef_seed = (deadbeef_seed << 7) ^ ((deadbeef_seed >> 25) + deadbeef_beef);

deadbeef_beef = (deadbeef_beef << 7) ^ ((deadbeef_beef >> 25) + 0xdeadbeef);

return (deadbeef_seed & 0x0000FFFF); // return rand number from 0x0000 to 0xFFFF

}