• 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.

    Code:
    SYMBOL SEED_POSITION = 0
     
    DIM tmp_seed as WORD
     
    'INITIALIZATION
    '===========
     
    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

    xldaedalus-432

    Mysterious PORTB problem

    Thread Starter: xldaedalus

    I'm using Proton+ to develop firmware for a product with switches. The MCU is an 18F26K22. Most of the switches reside on PORTB. I am NOT using a...

    xldaedalus Yesterday, 23:49 Go to last post
    tumbleweed-20435

    Watchdog timer

    Thread Starter: joesaliba

    I have a code that basically looks for four input and four outputs, depends on various timing and input conditions. I use interrupt and some delays...

    tumbleweed Yesterday, 19:54 Go to last post