Proton BASIC Compiler - Random Generator with no external components

  • PicŪ Basic

  • Random Generator with no external components

    The code works only on devices with some spare EEPROM (2 bytes) space. It consecutively uses seed values. Between runs, the seed is increased each time the PICŪ is startup. This way, each time the PICŪ is started a new value is entered as a seed and a new range of random numbers will be generated.

    BE CAREFULL: Only call this function on "startup" of the PICŪ to avoid wearing the EEPROM.

    It still is not a "real" random number but it is a quite good solution for those with no external resources able to generate a random number.

    DIM tmp_seed as WORD
    tmp_seed.lowbyte = EREAD SEED_POSITION
    tmp_seed.highbyte = EREAD SEED_POSITION + 1
    SEED tmp_seed
    INC tmp_seed
    EWRITE SEED_POSITION, [tmp_seed]
    contributed by Tom Van den Eede.
  • Recent Activity


    pic16f689 tx problem

    Thread Starter: hadv215

    I want to use the UART for testing purposes on my 16F689 application. Compiler Declare Hserial_Baud = 2400 Declare Hserial_RCSTA =...

    tumbleweed Today, 17:56 Go to last post