RCTIME Example | Syntax |
' ------------------------------------------------------------------------- ' Program Description ' ------------------------------------------------------------------------- ' ' Reads a POT using RCTIME and converts to a decimal digit, 0 - 9. ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ID "RCTIME" ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- PotPin VAR RA.0 ' IO pin for RCTIME Display VAR RB ' 7-segment LED TRIS_Disp VAR TRIS_B ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- analog VAR Word ' pot value WATCH analog ' ========================================================================= PROGRAM Start ' ========================================================================= ' ------------------------------------------------------------------------- ' Program Code ' ------------------------------------------------------------------------- Start: Display = %00000000 ' clear display TRIS_Disp = %00000000 ' display port --> outputs Main: HIGH PotPin ' charge capacitor PAUSEUS 250 ' for 250 usecs RCTIME PotPin, 1, analog ' read pot (2 us units) analog = analog / 50 ' convert to 0 - 9 READ SegMap + analog_LSB, Display ' put digit into display PAUSE 100 ' wait 0.1 secs GOTO Main ' ========================================================================= ' User Data ' ========================================================================= SegMap: ' segments maps ' .gfedcba DATA %00111111 ' 0 DATA %00000110 ' 1 DATA %01011011 ' 2 DATA %01001111 ' 3 DATA %01100110 ' 4 DATA %01101101 ' 5 DATA %01111101 ' 6 DATA %00000111 ' 7 DATA %01111111 ' 8 DATA %01100111 ' 9