I have four inputs on PortA that I want to read pulse values from but not at the same time. Say I have a subroutine to read PortA pin 0, grab the pulse length from it, then return to the calling subroutine, then I want to use the same pulse reading subroutine to grab the pulse length on PortA pin 1 and so on. Is there a way to do this or do I have to write a separate subroutine for each pin on PortA. The reason I ask is because I am using BTFSC PORTA, PIN to wait until the pin goes low. My understanding of BTFSC is that the bit (PIN) value must be a literal and cannot be stored in a register. If I tried to use a register value it would take the actual address of the register and try to use that instead of what is contained in the register. Do I understand that correctly? Is there a trick to doing what I want to do? Here is a snippet of my source code so you can get a better idea of what I'm trying to do. As you will see, The four subroutines basically do the exact same thing with the exception of reading a different pin on PortA and writing to one of four different registers. This would not be a problem except this fills half of my program memory on my 16F84A and this code is only a third or so of the end program. If there is no work around, should I just move to a PIC with more program memory? Thanks in advance. Sincerely, Scott Pierce MAINLOOP CALL ROLL_PULSE CALL PITCH_PULSE CALL THROTTLE_PULSE CALL YAW_PULSE GOTO MAINLOOP ;============================================================================== ROLL_PULSE CLRF ROL ;CLEAR ROL COUNTER ROL2 BTFSC PORTA,ROLP ;LOOP UNTIL PORTA,ROLP PIN IS CLEARED GOTO ROL2 ROL3 BTFSS PORTA,ROLP ;LOOP UNTIL PORTA,ROLP PIN IS SET GOTO ROL3 ROL4 INCF ROL ;INCREMENT ROL COUNTER CALL PAUSE BTFSC PORTA,ROLP ;LOOP UNTIL PORTA,ROLP PIN IS CLEARED GOTO ROL4 ;MOVF ROL,W ;LOAD W WITH ROL ;MOVWF PORTB ;LOAD PORTB WITH VALUE OF ROL RETURN ;============================================================================== PITCH_PULSE CLRF PIT ;CLEAR PIT COUNTER PIT2 BTFSC PORTA,PITP ;LOOP UNTIL PORTA,PITP PIN IS CLEARED GOTO PIT2 PIT3 BTFSS PORTA,PITP ;LOOP UNTIL PORTA,PITP PIN IS SET GOTO PIT3 PIT4 INCF PIT ;INCREMENT PIT COUNTER CALL PAUSE BTFSC PORTA,PITP ;LOOP UNTIL PORTA,PITP PIN IS CLEARED GOTO PIT4 ;MOVF PIT,W ;LOAD W WITH PIT ;MOVWF PORTB ;LOAD PORTB WITH VALUE OF PIT RETURN ;============================================================================== THROTTLE_PULSE CLRF THR ;CLEAR THR COUNTER THR2 BTFSC PORTA,THRP ;LOOP UNTIL PORTA,THRP PIN IS CLEARED GOTO THR2 THR3 BTFSS PORTA,THRP ;LOOP UNTIL PORTA,THRP PIN IS SET GOTO THR3 THR4 INCF THR ;INCREMENT THR COUNTER CALL PAUSE BTFSC PORTA,THRP ;LOOP UNTIL PORTA,THRP PIN IS CLEARED GOTO THR4 ;MOVF THR,W ;LOAD W WITH THR ;MOVWF PORTB ;LOAD PORTB WITH VALUE OF THR RETURN ;============================================================================== YAW_PULSE CLRF YAW ;CLEAR YAW COUNTER YAW2 BTFSC PORTA,YAWP ;LOOP UNTIL PORTA,YAWP PIN IS CLEARED GOTO YAW2 YAW3 BTFSS PORTA,YAWP ;LOOP UNTIL PORTA,YAWP PIN IS SET GOTO YAW3 YAW4 INCF YAW ;INCREMENT YAW COUNTER CALL PAUSE BTFSC PORTA,YAWP ;LOOP UNTIL PORTA,YAWP PIN IS CLEARED GOTO YAW4 ;MOVF YAW,W ;LOAD W WITH YAW ;MOVWF PORTB ;LOAD PORTB WITH VALUE OF YAW RETURN ;============================================================================== -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads