summaryrefslogtreecommitdiffstats
path: root/test/boost/randtest.c
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 18:42:24 +0000
commitf508189682b6fba62e08feeb1596f682bad5fff9 (patch)
tree28aeb0e6c19386c385c1ce5edf8a92c1bca15281 /test/boost/randtest.c
downloadpiklab-f508189682b6fba62e08feeb1596f682bad5fff9.tar.gz
piklab-f508189682b6fba62e08feeb1596f682bad5fff9.zip
Added KDE3 version of PikLab
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/piklab@1095639 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'test/boost/randtest.c')
-rw-r--r--test/boost/randtest.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/boost/randtest.c b/test/boost/randtest.c
new file mode 100644
index 0000000..812dfd6
--- /dev/null
+++ b/test/boost/randtest.c
@@ -0,0 +1,48 @@
+/*
+ Random number generator sample for BoostC compiler.
+ Use the 'Led Block' plugin to see
+ changing random value on port B.
+*/
+
+#include <system.h>
+#include <rand.h>
+
+#pragma CLOCK_FREQ 20000000
+
+// Set configuration word
+#ifdef _PIC16
+ #pragma DATA 0x2007, _HS_OSC & _WDT_OFF
+#endif //_PIC16
+
+
+void main()
+{
+ trisb = 0; //configure port B
+ portb = 0;
+
+#ifdef _PIC16
+ option_reg = 7; //set prescaler
+
+ set_bit( intcon, GIE );
+ set_bit( intcon, T0IE ); //enable TMR0 overflow bit
+#else
+ clear_bit( t0con, T0CS ); // select internal clock
+ clear_bit( t0con, PSA ); // select pres-scaler
+ set_bit( t0con, T0PS0 ); // set pres-scaler to 1:256
+ set_bit( t0con, T0PS1 );
+ set_bit( t0con, T0PS2 );
+
+ // enable interrupts
+ set_bit( intcon, GIE );
+ set_bit( intcon, TMR0IE ); //enable TMR0 overflow bit
+#endif
+
+ //Set ramdom number generator seed
+ srand( 0x1234 );
+
+ while( 1 ) //endless loop
+ {
+ portb = rand();
+ delay_ms( 100 );
+ }
+}