In SX Microcontrollers, SX/B Compiler and SX-Key Tool, mspeedie wrote: Here's an explanation of the following code: I ran the RCTime function 100 times, and timed the counter loop. The entire process took 64 seconds. Subtracting (100*20ms pause=2s), the total time for the 100 RCTime routines took 62 seconds. This is 620ms per RCTime function. This makes no sense to me as running the command using the BASIC Stamp takes about 2ms. So, here's the code... I'm attaching a picture of the SX proto board (ignore the red wires, they are my home-made Vin). I have two resisters in series coming from pin rb.7 totalling approximately 220-ohms, then a 0.1uF cap and 15k-ohm in parallel to ground. ' ========================================================================= ' ' File...... test RC-Time Circuit 2009-04-25.sxb ' Purpose... test rc-time ' Author.... ' E-mail.... ' Started... ' Updated... 2009- ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- PhotoR PIN RB.7 ' RC-Time from photo-resistor ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- T VAR Word ' ------------------------------------------------------------------------- INTERRUPT ' ------------------------------------------------------------------------- ISR_Start: ' ISR code here ISR_Exit: RETURNINT ' {cycles} ' ========================================================================= PROGRAM Start ' ========================================================================= Pgm_ID: DATA "SX/B Template", 0 ' ------------------------------------------------------------------------- ' Subroutines / Jump Table ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: ' initialization code here Main: ' main code here COUNTER = 0 high ra.0 do while counter < 100 HIGH PhotoR pause 20 PULSIN PhotoR, 1, T counter = counter + 1 loop low ra.0 do loop GOTO Main ' ------------------------------------------------------------------------- ' Page 1 Code ' ------------------------------------------------------------------------- 'Page_1: ' ADDRESS $200 'P1_Start: ' GOTO P1_Start ' error if Pg0 overruns Pg1 ' ------------------------------------------------------------------------- ' Page 2 Code ' ------------------------------------------------------------------------- 'Page_2: ' ADDRESS $400 'P2_Start: ' GOTO P2_Start ' error if Pg1 overruns Pg2 ' ------------------------------------------------------------------------- ' Page 3 Code ' ------------------------------------------------------------------------- 'Page_3: ' ADDRESS $600 'P3_Start: ' GOTO P3_Start ' error if Pg3 overruns Pg4 ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=329983#m347010 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)