This uses the following code
http://www.dougrice.plus.com/dev/cn001/cn001.asm
This was my first go with a 10F204. It uses the TMR0 to generate timer events.
; Notes: * ; ; PICkit2 Programming Header 10F204 ; 1 Vpp,/MCLR p8 ; 2 Vdd p2 ; 3 Vss p7 ; 4 ICSPDAT,PGD p5 ; 5 ICSPCLK,PGC p4 ; 6 AUX ;
This uses a PRBS to produce a random flasher. WDT is used as a timer. The chip sleeps until woken up by the WDT.
http://www.dougrice.plus.com/dev/cn001/cn004.asm
http://www.dougrice.plus.com/dev/cn001/cn005.asm
A post on the Microchip Forum had a requirement to have a random start up.
There is no EEPROM to remember the state when it was turned off.
It was suggested that the WDT be used. The chip has two independent oscillators, which are set to free run and sampled after a number of cycles. It may be possible to use the least significant bits as a seed for a random number.
Hopefully the temperature affects the frequencies of the two oscillators differently.
Using the modulus of the ratio of the two frequencies is used.
This is very simple and produced a flickering flasher, which did lock up at certain temperatures.
This worked and it was very simple.
The demo starts TMR0 at a fast speed and then uses the WDT to reset the processor. TMR0 is samples, and in this demo, the bottom three bits are output onto the LEDs
; PICkit 2 demo - Random Numbers by measuring the WDT time out period. ; Doug Rice, www.dougrice.plus.com or http://www.doug.h.rice.btinternet.co.uk/ on 05/08/2010
Being an RC based oscillator, the WDT timeout will have a noise element, hence an element of randomness.
Uses WDT and TMR0 TMR1 to produce random number.
WDT is allowed to time out and TMR0 and or TMR1 is read on timeout. TMR0 and TMR1 are reset for the next measurement.
Temperature affects the WDT and clock frequencies so produces a noisy 'random' value.
Output the value to the serial port to measure the values to see how random the numbers are.
Serially output using the UART.
Using 16F690 on LowCost Demo Board, connect RB7 to RA0 with 100 ohm resistor ( for protection )
Use PICkit 2 v2.50 and UART tool at 9600 baud
You can use the PICkit2 UART tool to log the serial output to a csv file to import into Excel.
Uses PICkit 2 Starter Kit DV164120
http://www.dougrice.plus.com/dev/cn001/rand001.asm
here is a plot of some TMR1 timeout values produced with the code above on a PIC kit 2.
http://www.dougrice.plus.com/dev/cn001/cn006.asm