Ayuda con programación de PIC

hola, me encargaron programar un PIC para una secuencia que consiste en clasificar cajas en una línea de producción, las instrucciones incluyen el manejo de unas pinzas y giros del motor
sin embargo a la hr de implementar el pic ... no hace nada:LOL:
tengo dudas si declaré bien los puertos de entrada y salida
quiero 8 entradas y 6 salidas

les pongo el código

list p=16f877A ; list directive to define processor
#include <p16f877A.inc> ; processor specific variable definitions


;***** VARIABLE DEFINITIONS
w_temp EQU 0x70 ; variable used for context saving
status_temp EQU 0x71 ; variable used for context saving
pclath_temp EQU 0x72 ; variable used for context saving

CUENBAJA EQU 0X26
CUENBAJA2 EQU 0X27


;**********************************************************************
ORG 0x000 ; processor reset vector

nop ; nop required for icd
goto main ; go to beginning of program


ORG 0x004; interrupt vector location

movwf w_temp; save off current W register contents
movf STATUS,w; move status register into W register
movwf status_temp; save off contents of STATUS register
movf PCLATH,w; move pclath register into w register
movwf pclath_temp; save off contents of PCLATH register
RETFIE

main
start

CALL INIT_B ; Inicializo puerto B como entradas.
CALL INIT_A ; Inicializo puerto A como salidas.
BCF STATUS, RP0 ; Regreso al banco 0
BCF STATUS, RP1 ;
GOTO WAIT ; Llamo secuencia WAIT

WAIT
BTFSS PORTA,0 ; inicialización por un switch
GOTO WAIT
GOTO INIT_SQ1


INIT_SQ1 ;se comienzan a cerrar las pinzas

MOVLW b'00001001' ; salida1
MOVWF PORTB ; Saco W por puerto B
BTFSC PORTA,1 ;detecta el sensor de contacto
GOTO INIT_SQ2 ;
GOTO INIT_SQ1 ;


;ciclo

INIT_SQ2 ; clasifica las cajas

BTFSS PORTA,6
GOTO INIT_SQ3 ;caja azul
GOTO INIT_SQ6 ;caja roja

INIT_SQ3 ;caja azul

MOVLW b'00010000' ;gira a la izquierda
MOVWF PORTB
BTFSC PORTA,2
GOTO INIT_SQ4
GOTO INIT_SQ3

INIT_SQ4 ;abre las pinzas
MOVLW b'00000110'
MOVWF PORTB
BTFSC PORTA,3
GOTO INIT_SQ5
GOTO INIT_SQ4

INIT_SQ5
MOVLW b'00001000' ;regresa al estado original gira a la derecha
MOVWF PORTB
BTFSC PORTA,5
GOTO WAIT
GOTO INIT_SQ5
INIT_SQ6 ;caja roja
MOVLW b'00001000' ;gira a la derecha
MOVWF PORTB
BTFSC PORTA,4
GOTO INIT_SQ7
GOTO INIT_SQ6
INIT_SQ7
MOVLW b'00000110' ; abre las pinzas
MOVWF PORTB
BTFSC PORTA,3
GOTO INIT_SQ8
GOTO INIT_SQ7
INIT_SQ8
MOVLW b'00010000' ;gira a la izquierda
MOVWF PORTB
BTFSC PORTA,7
GOTO WAIT
GOTO INIT_SQ8

;BUCLE1

; MOVLW b'00001111'
; MOVWF CUENBAJA2
;DECRE
; DECFSZ CUENBAJA2,1
; GOTO DECRE
; DECFSZ CUENBAJA, 1
; GOTO BUCLE1
; RETURN

INIT_B ; Inicialización de Puerto B como entrada

BCF STATUS, RP0 ;
BCF STATUS, RP1 ; Bank0
CLRF PORTB ;
BSF STATUS, RP0 ; Select Bank 1
MOVLW 0x08 ; Configure all pins
MOVWF ADCON1 ; as digital inputs
MOVLW 0xFF ; Value used to
MOVWF TRISB ; Set RA<3:0> as inputs

INIT_A ; Inicialización de Puerto A. como salida

BCF STATUS, RP0 ;
BCF STATUS, RP1 ; Bank0
CLRF PORTA ; Initialize PORTA by
BSF STATUS, RP0 ; Select Bank 1
MOVLW 0x00
MOVWF TRISA ; Set RA<3:0> as inputs

END ; directive 'end of program'


gracias
 
Atrás
Arriba