; ; *************************************************************************** ; *** Bubble Software Parallax to PIC Source Converter. Copyright 1999. *** ; *** http://www.picnpoke.com email: sales@picnpoke.com *** ; *************************************************************************** ; ; LOOKUP index (in w), table ; Finds the table entry corresponding to index (in w) and ; returns it in w. This demonstration uses a table to map the ; numbers 0 through F hex to patterns on a seven-segment LED ; display. It assumes that the display is connected with segment ; a to rb.0, b to rb.1... and g to rb.6 through current-limiting ; resistors of 220 ohms minimum. When the program runs, it counts ; upward 0, 1, 2, 3...through F, then begins the count again at 0. ; Device data and reset vector P = pic16c55 #include <16c55.inc> ; processor assembler definitions _CONFIG _xt_osc & _wdt_off & _protect_off reset start org 8 count Res d'1' ; Counter variable for demo. temp Res d'1' ; Variables for delays temp2 Res d'1' ; used in demo subroutines. org 0 Lookup ADDWF pcl ; Jump to entry spec'd by w. RETLW d'63' ; 0, 1, 2, 3 RETLW d'6' RETLW d'91' RETLW d'79' RETLW d'102' ; 4, 5, 6 RETLW d'109' RETLW d'125' RETLW d'7' ; 7, 8, 9 RETLW d'127' RETLW d'103' RETLW d'119' ; A, B, C RETLW d'124' RETLW d'57' RETLW d'94' ; D, E, F RETLW d'121' RETLW d'113' start MOVLW d'0' ; All outputs for LEDs TRIS 6h CLRF 6h ; All LEDs off to begin. CLRF count ; Start count at 0. start_loop MOVF count,w ; Put number to look up into w. ANDLW b'00001111' ; Strip off high bits. CALL Lookup ; Call the table. MOVWF 6h ; Write pattern in w to LEDs. start_wait DECFSZ temp ; Short delay. GOTO start_wait DECFSZ temp2 GOTO start_wait INCF count ; count = count + 1 GOTO start_loop ; Do it again. end