' ========================================================================= ' File....... SSW21-EX03-Counter_LEDs.SXB ' Purpose.... Advanced LED Flasher ' Author..... (C) 2000 - 2005, Parallax, Inc. ' E-mail..... support@parallax.com ' Started.... 01 SEP 2005 ' Updated.... 23 MAR 2007 by TSaavik for SX28 ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' ' Displays a 4-bit binary counter on LEDs connected to RB.0 - RB.3. This ' program will work, unmodified, on the SX28. '------{ Device Settings ]------------------------------------------------- DEVICE SX28,TURBO,BANKS8,OSCHS3,SYNC,OPTIONX FREQ 50_000_000 ID "EX03" ' -----[ I/O Definitions ]------------------------------------------------- LEDs VAR RB ' LEDs on RB.0 - RB.3 ' -----[ Constants ]------------------------------------------------------- MinCount CON 0 ' counter start value MaxCount CON 15 ' counter end value 'DelayTm CON 100 ' delay time for LEDs DelayTm CON 1 ' delay time for LEDs in SXSIM ' -----[ Variables ]------------------------------------------------------- cntr VAR Byte ' 4-bit counter variable, but not really ' -----[ Initialization ]------------------------------------------------- PROGRAM Start watch cntr watch RB,8,ubin ' -----[ Program Code ]---------------------------------------------------- Start: TRIS_B = %11110000 Main: DO FOR cntr = MinCount TO MaxCount ' loop through all values LEDs = cntr ' move count to LEDs PAUSE DelayTm ' hold a bit break NEXT LOOP ' repeat forever