In SX Microcontrollers, SX/B Compiler and SX-Key Tool, basicstampede wrote: Jonny Mac, below, please see my entire code. Thanks for all your help. ' ========================================================================= ' ' File...... Stampworks10 ' Purpose... Stampworks 10 in SX/B ' Author.... C.M. ' E-mail.... ' Started... Sept. 1, 2008 ' Updated... ' ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' 8 digit LED ' takes input square voltage in TicPin (RB.0) and uses this as timing signal ' displays time in four 8 segment LEDs ' uses time multiplexing and persistence of vision ' ------------------------------------------------------------------------- ' Conditional Compilation Symbols ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX, BOR42 FREQ 4_000_000 ' ------------------------------------------------------------------------- ' I/O Pins ' ------------------------------------------------------------------------- Segs PIN RC OUTPUT TicPin PIN RB.0 INPUT DigSel PIN RA OUTPUT ' ------------------------------------------------------------------------- ' Constants ' ------------------------------------------------------------------------- Blank CON 0 Dig0 CON %1111 'all digits off Dig1 CON %0111 'tens minutes digit Dig2 CON %1011 'ones minutes digit Dig3 CON %1101 'tens seconds digit Dig4 CON %1110 'ones seconds digit ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- 'idx VAR Byte counter VAR Byte sec VAR Byte seconds VAR Byte minutes VAR Byte sec_ones VAR Byte sec_tens VAR Byte min_ones VAR Byte min_tens VAR Byte digit VAR Byte digitvalue VAR Byte value VAR Byte pinstatus VAR Byte time VAR Byte oldpin VAR Byte newpin VAR Byte result VAR Byte ' ========================================================================= ' INTERRUPT ' ========================================================================= 'ISR_Start: ' ISR code here 'ISR_Exit: 'RETURNINT ' {cycles} ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Subroutine / Function Declarations ' ------------------------------------------------------------------------- SHOW_TIME SUB 0 UPDATE_TIME SUB 0 ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: counter = 0 sec = 0 digit = 0 DigSel = Dig0 newpin = TicPin Main: SHOW_TIME oldpin = newpin newpin = TicPin result = oldpin ^ newpin IF result <> 0 THEN counter = counter + 1 IF counter = 2 THEN counter = 0 UPDATE_TIME ELSE 'only changed 1 time 'oldpin = newpin ' try adding more code here ENDIF ELSE 'oldpin = newpin ' try adding more code here ENDIF WATCH sec WATCH seconds WATCH minutes WATCH sec_ones WATCH sec_tens WATCH min_ones WATCH min_tens WATCH value WATCH digitvalue WATCH oldpin WATCH newpin BREAK GOTO Main ' ------------------------------------------------------------------------- ' Subroutine / Function Code ' ------------------------------------------------------------------------- SUB SHOW_TIME 'Segs = Blank ' try activating this digSel = Dig4 READ DecDig+sec_ones, Segs PAUSE 1 digSel = Dig3 READ DecDig+sec_tens, Segs PAUSE 1 digSel = Dig2 READ DecDig+min_ones, Segs PAUSE 1 digSel = Dig1 READ DecDig+min_tens, Segs PAUSE 1 DigSel = Dig0 'need this? try eliminating this. ' ENDSUB SUB UPDATE_TIME sec = sec + 1 IF sec=60 THEN sec = 0 sec_tens = 0 sec_ones = 0 min_ones = min_ones + 1 IF min_ones = 10 THEN min_ones = 0 min_tens = min_tens + 1 IF min_tens = 9 THEN min_tens = 0 ENDIF ENDIF ELSE sec_tens = sec / 10 sec_ones = sec // 10 ENDIF ENDSUB ' ------------------------------------------------------------------------- ' ------------------------------------------------------------------------- ' User Data ' ------------------------------------------------------------------------- DecDig: DATA %01111110 '0 DATA %00110000 '1 DATA %01101101 '2 DATA %01111001 '3 DATA %00110011 '4 DATA %01011011 '5 DATA %01011111 '6 DATA %01110000 '7 DATA %01111111 '8 DATA %01111011 '9 DATA %01110111 'A DATA %00011111 'b DATA %01001110 'C DATA %00111101 'd DATA %01001111 'E DATA %01000111 'F ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=290897#m291106 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)