; ; *************************************************************************** ; *** Bubble Software Parallax to PIC Source Converter. Copyright 1999. *** ; *** http://www.picnpoke.com email: sales@picnpoke.com *** ; *************************************************************************** ; ; HIGH port (in w), pin ; Outputs a high to the specified port and pin. ; Device data and reset vector P = pic16c55 #include <16c55.inc> ; processor assembler definitions _CONFIG _xt_osc & _wdt_off & _protect_off reset start org 8 pin Res d'1' ; Pin number to set (0-7). ; Variables for the demo program--not required by High. p_index Res d'1' ; Copy of pin number, port number. temp Res d'1' ; Temporary variables for time delay temp2 Res d'1' ; between outputs. org 0 ; Table to convert pin number (0-7) into bit mask (00000001b to 10000000b). Pinz ADDWF pcl RETLW d'1' RETLW d'2' RETLW d'4' RETLW d'8' RETLW d'16' RETLW d'32' RETLW d'64' RETLW d'128' ; The following demonstration code should show the value of being able to ; set a particular bit of a port based on a calculation performed while the ; program is running. As the variable p_index is incremented from 0 to 15, ; it is used to specify the pin and port to set using High. start MOVLW d'0' ; All outputs on rb. TRIS 6h MOVLW d'0' ; All outputs on rc. TRIS 7h CLRF 6h ; Start with 0s on rb, rc (all LEDs off). CLRF 7h CLRF p_index ; Clear p_index. start_loop MOVLW d'7' ; Copy three lsbs of p_index into MOVWF pin MOVF p_index ; variable pin. ANDWF pin MOVLW d'1' ; IF p_index.3 = 0 BTFSC p_index,d'3' ; THEN w = 1 MOVLW d'2' ; ELSE w = 2 CALL High CALL delay ; Wait a while between highs. INCF p_index ; Next pin/port. BTFSS p_index,d'4' ; IF p_index < 15 (rc.7) GOTO start_loop ; THEN :loop ELSE done done GOTO $ ; Endless loop. ; HIGH (cont) ; To use the routine High, put the pin number into the variable pin ; and the port number into w. Then call High. High MOVWF fsr ; Point to the port number. MOVLW 5h ; Add offset for port RA. ADDWF fsr MOVF pin,w CALL Pinz ; Get bit mask from the table. IORWF indirect ; Turn on the selected bit RETLW 0h ; Delay routine for demonstration. Not required by High. delay DECFSZ temp ; Time delay to provide spacing GOTO delay DECFSZ temp2 ; between highs. GOTO delay RETLW 0h end