Autor Tema: Hacer una interrupcion  (Leído 2028 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado sQs

  • PIC10
  • *
  • Mensajes: 47
Hacer una interrupcion
« en: 30 de Mayo de 2011, 15:31:43 »
Hola buen dia a todos.

Estoy intentando hacer una interrupcion que al ejecutarse aga una especie de pausa, la verdad no se si sea mejor opcion hacerlo por medio de un ciclo, les explico un poco a detalle.

Estoy usando el PIC 12F683 y quiero que todo el proceso se aga a travez del puerto GP1 del PIC, lo que necesito hacer es que en un principio este puerto este declarado como entrada y que al detectar una entrada de valores se ejecute una demora de 500 ms, terminando la demora que cambie a salida y mande una señal por el mismo puerto (GP1), y despues vuelva a estar como entrada esperando nuevamente la entrada de valor para asi repetir el proceso.

No se si esto sea mas conveniente por interrupcion o sea mas sencillo por un ciclo que simplemente se este ejecutando haciendo la comparacion del puerto.

Si alguien por favor pudiera ayudarme, la verdad soy muy novato en ASM y si me ayudan en algo por favor lo mas que me pudieran explicar o dar algunos ejemplos, se los agradeceria infinitamente.

Desconectado Suky

  • Moderador Local
  • DsPIC33
  • *****
  • Mensajes: 6758
Re: Hacer una interrupcion
« Respuesta #1 en: 30 de Mayo de 2011, 15:52:37 »
Es más sencillo hacer lo ultimo que comentas. Porque mientras pasan los 500ms no tienes que realizar absolutamente nada, en cambio si necesitas realizar otras tareas, si se haría por interrupción. Por aquí un par de ejemplos:

http://www.todopic.com.ar/foros/index.php?topic=24720.0


Saludos!
No contesto mensajes privados, las consultas en el foro

Desconectado sQs

  • PIC10
  • *
  • Mensajes: 47
Re: Hacer una interrupcion
« Respuesta #2 en: 30 de Mayo de 2011, 17:12:25 »
Estuve checando los tutos que tienes (Mis primeros programas en ASM. PIC16F84A y PIC16F628A/648A), y la verdad que me parece facil con ese PIC pero con este se me complica un poco, trato de hacer lo mismo cambiando PORTB por TRISIO o GPIO pero no me funciona nada, como puedo cambiar esta parte de codigo al PIC 12F683 usando el puerto GP1 para el LED y el puerto GP3 para el activador?.
Bueno solo que en mi caso yo necesitaria que el Activador fuese algo asi como el LED tambien.

Tal vez ya te enrede un poco pero te explico mas claro lo que necesito lograr:
- GP4 estara como salida unicamente
- Se hara la comparacion si GP4 esta activa la salida
- En caso de estarlo se hara otra comparacion, de si esta recibiendo señal GP1
- Y en caso que este alla recibido una señal, se hara una demora (por ejemplo 500 ms, esta yo la estare variando por medio de una variable) y se enviara una señal al mismo puerto GP1 (digamos como un parpadeo muy rapido).


Se me hace complicado porque no domino correctamente las entradas y salidas y para mi mala fortuna es muy poca la informacion que logro encontrar para este PIC y la que encuentro esta en Basic o C, la mayoria utiliza los 16 o 18.


Les pongo algo del programa que estoy editando haber si me pueden ayudar un poco.
Código: ASM
  1. list      p=12F683        ; list directive to define processor
  2.         #include <p12F683.inc>    ; processor specific variable definitions
  3.  
  4.         errorlevel  -302          ; suppress message 302 from list file
  5.  
  6.         __CONFIG   _FCMEN_OFF & _IESO_OFF & _CP_ON & _CPD_ON & _BOD_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTOSCIO
  7.  
  8. ;***** VARIABLE DEFINITIONS******************
  9. w_temp        EQU     0x70        ; variable used for context saving
  10. status_temp   EQU     0x71        ; variable used for context saving
  11.  
  12. FLAGS           EQU             0x20            ;software state register
  13. PULSER          EQU             0x21            ;pulse on counter
  14. DWELLTIMER      EQU             0x22            ;pulse off counter
  15. STATE           EQU             0x23            ;programmed state
  16. BUTTONHOLD      EQU             0x24
  17. FREQR           EQU             0x25            ;frequency value
  18. TEMP1           EQU             0x26
  19. TEMP2           EQU             0x27
  20. PULSEL          EQU             0x28
  21. DWELLTIMEL      EQU             0x29
  22. TEMP5           EQU             0x2A
  23. LEDBLINK        EQU             0x2B
  24. TEMP3           EQU             0x2C
  25.  
  26.  
  27. BURSTRATE       EQU             0x63 ;3E
  28. BURSTRight      EQU             0x64 ;3F
  29. BURSTLeft       EQU             0x65
  30. FLAGS2          equ             0x66 ;41
  31. SHADOWP         equ             0x67 ;42
  32.  
  33.  
  34. LEDActivado             equ             0x68 ;43
  35. DATOSEE                 equ             0x69 ;44
  36. DIRECCIONEE             equ             0x6A ;45
  37. DESACTIVADO     equ             0x6B ;46
  38. TEMPFREE                equ             0x6C ;47
  39. TEMPLED3EE              equ             0x6D ;48
  40. TEMPLED3EEconta equ             0x6E ;49
  41. TEMPLED4EE              equ             0x6F ;4A
  42. TEMPLED4EEconta equ             0x72 ;4B
  43. HAYCAMBIO               equ             0x73 ;4C
  44. TEMP                    equ             0x74 ;4D
  45. TEMPFastForward equ             0x75
  46. TEMPFastRewind  equ             0x76
  47. TEMPFast                equ             0x77
  48.  
  49.  
  50.  
  51. ;*******bits in FLAGS register***********
  52. PULSEONR                equ             0
  53. PULSEONL                equ             1
  54. TRIGOUT                 equ             2
  55. LEDHI                   equ             3
  56. STATECHANGE             equ             4
  57. BURSTACTIVE             equ             6
  58. COD5MODE                equ             7
  59.  
  60. ;******bits in FLAGS2 register
  61. BDWELLRT        equ             0
  62. BDWELLLT        equ             1
  63. BURSTONR        equ             2
  64. BURSTONL        equ             3
  65.  
  66.  
  67. ActLEDIzq       equ             1
  68. ActLEDDer       equ             0
  69.  
  70.  
  71. ;*******bits in STATE register***********
  72. RIGHTACTIVE             equ             0
  73. LEFTACTIVE              equ             1
  74.  
  75. ;*********GPIO pin names*****************
  76. LEDL                    equ             4
  77. LEDR                    equ             5
  78. BUTTONR                 equ             2
  79. BUTTONL                 equ             3
  80. TRIGGERR                equ             0
  81. TRIGGERL                equ             1
  82.  
  83.  
  84.  
  85.  
  86. ;**********************************************************************
  87.         ORG     0x000             ; processor reset vector
  88.         goto    main              ; go to beginning of program
  89.        
  90.  
  91.         ORG     0x004             ; interrupt vector location
  92.         movwf   w_temp            ; save off current W register contents
  93.         movf    STATUS,w          ; move status register into W register
  94.         movwf   status_temp       ; save off contents of STATUS register
  95.  
  96.                         ;Take a good note here. OSC is left at default 4MHz.
  97.                         ; We are running at 1MHz instruction cycle, or 1 micro second
  98.                         ;Timer 2 is prescaled 1:4 and compared (PR2) to 250.
  99.                         ; we now have hardware interupt that falls every 1ms exactly
  100.                         ;within limitation of osctune. Main code is inconsequential.
  101.                         ;PULSE and DWELL values control the signals precisely.
  102.                         ;All pulse logic is switched within the few microseconds to
  103.                         ;service the interupt routine. DO NOT modify the ISR
  104.                         ;with any kind of 'wait' or 'loop'. If you want to trigger
  105.                         ; timed events do so by setting an open FLAG bit and have the
  106.                         ;event done in the main loop.
  107.  
  108.  
  109.         btfss   PIR1, TMR2IF            ;timer 2 int happened
  110.         retfie
  111.  
  112. ;**************** Interruptions *********************************************
  113.                                                                 ;Our main routine will turn the flag bit
  114.                                                                 ;LEDON on or off. The 10ms pulse is a duty cycle
  115.                                                                 ;for the code to work with both CG and
  116.                                                                 ;matrix controllers.
  117.  
  118. ;**************** Tactiles push logic **************************************
  119.  
  120. BlinkLed       
  121.         btfss   FLAGS, LEDHI
  122.         goto    LedLow
  123.         decfsz  LEDBLINK, f                     ;if pulse is active, count down 10ms
  124.         goto    RightLED
  125.         movlw   0x0A
  126.         movwf   LEDBLINK
  127.         bcf             FLAGS, LEDHI            ;10ms done, turn off LEDHI bit
  128.         goto    RightLED
  129. LedLow
  130.         decfsz  LEDBLINK, f                     ;LEDLO time, count down 10ms
  131.         goto    RightLED
  132.         movlw   0x0A
  133.         movwf   LEDBLINK
  134.         bsf             FLAGS, LEDHI            ;10ms done, turn LEDHI bit on
  135.  
  136. RightLED
  137.         btfsc   STATE, RIGHTACTIVE      ;is RF on?
  138.         goto    OutputRightLED
  139.         bsf             STATUS, RP0                     ;bank 1
  140.         bsf             TRISIO, LEDR            ;tristate LED
  141.         bcf             STATUS, RP0                     ;bank 0
  142.         goto    LeftLED
  143. OutputRightLED
  144.         btfsc   FLAGS, LEDHI            ;if ledhi true,
  145.         bsf             GPIO, LEDR                      ;turn output hi
  146.         btfss   FLAGS, LEDHI            ;if ledhi flase,
  147.         bcf             GPIO, LEDR                      ;turn led output lo
  148.         bsf             STATUS, RP0                     ;bank 1
  149.         bcf             TRISIO, LEDR            ;turn output on
  150.         bcf             STATUS, RP0                     ;bank 0
  151.  
  152. LeftLED
  153.         btfsc   STATE, LEFTACTIVE       ;is RF on?
  154.         goto    OutputleftLED
  155.         bsf             STATUS, RP0                     ;bank 1
  156.         bsf             TRISIO, LEDL            ;tristate LED
  157.         bcf             STATUS, RP0                     ;bank 0
  158.         goto    RightTrigger
  159. OutputleftLED
  160.         btfsc   FLAGS, LEDHI            ;if ledhi true,
  161.         bsf             GPIO, LEDL                      ;turn output hi
  162.         btfss   FLAGS, LEDHI            ;if ledhi flase,
  163.         bcf             GPIO, LEDL                      ;turn led output lo
  164.         bsf             STATUS, RP0                     ;bank 1
  165.         bcf             TRISIO, LEDL            ;turn output on
  166.         bcf             STATUS, RP0                     ;bank 0
  167.  
  168.  
  169. ;**************** Right trigger logic***************************************   
  170. RightTrigger
  171. ;**************** Disparar en modo programacion
  172.         btfsc   DESACTIVADO, 1
  173.         goto    ActiveR
  174. ;**********************************************
  175.         btfsc   STATE, RIGHTACTIVE      ;is RF on?
  176.         goto    ActiveR
  177.         bsf             STATUS, RP0                     ;bank 1
  178.         bsf             TRISIO, TRIGGERR        ;output off
  179.         bcf             STATUS, RP0                     ;bank 0
  180.         goto    EndInterupt
  181.  
  182. ActiveR
  183.         btfss   FLAGS, TRIGOUT          ;controllertype
  184.         bcf             GPIO, TRIGGERR          ;determines
  185.         btfsc   FLAGS, TRIGOUT          ;output state
  186.         bsf             GPIO, TRIGGERR 
  187.  
  188.         btfsc   FLAGS, BURSTACTIVE
  189.         goto    BurstfireR
  190.  
  191.         btfss   FLAGS, PULSEONR         ;is pulse active?
  192.         goto    OffstateR
  193.         decfsz  PULSER, f                       ;if pulse is active, count down 10ms
  194.         goto    EndInterupt
  195.  
  196.         bcf             FLAGS, PULSEONR         ;10ms is over, clear flags and
  197.         bsf             STATUS, RP0                     ;bank 1
  198.         bsf             TRISIO, TRIGGERR        ;tristate output
  199.         bcf             STATUS, RP0                     ;bank 0
  200.         movf    FREQR, w                        ;and reset pulse time.
  201.         movwf   PULSER
  202.  
  203.         btfss   FLAGS, COD5MODE                 ;test COD5 mode
  204.         goto    EndInterupt
  205.         bcf             STATUS, C
  206.         rrf             PULSER, f                       ;25% DUTYCYCLE for COD5 release
  207.  
  208.         goto    EndInterupt
  209.  
  210. OffstateR
  211.         decfsz  DWELLTIMER, f           ;count down dwell time to next pulse
  212.         goto    EndInterupt
  213.         bsf             FLAGS, PULSEONR         ;if dwell is done turn on outputs
  214.         bsf             STATUS, RP0                     ;bank 1
  215.         bcf             TRISIO, TRIGGERR        ;and reset pulse time
  216.         bcf             STATUS, RP0                     ;bank 0
  217.         movf    FREQR, w                        ;from frequency value
  218.         movwf   DWELLTIMER
  219.  
  220.         btfss   FLAGS, COD5MODE                 ;test COD5 mode
  221.         goto    EndInterupt
  222.         bcf             STATUS, C
  223.         rrf             DWELLTIMER, f  
  224.         addwf   DWELLTIMER, f           ;75% dutycycle for pull
  225.  
  226. BurstfireR
  227. ;**************** Disparar en modo programacion
  228.         btfsc   DESACTIVADO, 1
  229.         goto    $+3
  230. ;**********************************************
  231.         btfss   FLAGS2, BURSTONR
  232.         goto    EndInterupt
  233.         btfsc   FLAGS2, BDWELLRT                ;burst fire
  234.         goto    BurstDwellR
  235.         btfss   FLAGS, PULSEONR                 ;is pulse active?
  236.         goto    OffstateR2
  237.         decfsz  PULSER, f                       ;if pulse is active, count down 10ms
  238.         goto    EndInterupt
  239.         bcf             FLAGS, PULSEONR         ;10ms is over, clear flags and output
  240.         bsf             STATUS, RP0             ;bank 1
  241.         bsf             TRISIO, TRIGGERR        ;and reset pulse time.
  242.         bcf             STATUS, RP0             ;bank 0
  243.         movf    FREQR, w
  244.         movwf   PULSER
  245.         btfsc   FLAGS, COD5MODE                 ;test COD5 mode
  246.         rrf             PULSER, f
  247.         decfsz  BURSTRight, f                           ;count down burst shots
  248.         goto    EndInterupt
  249.         movf    BURSTRATE, w                    ;reset counter
  250.         movwf   BURSTRight
  251.         bsf             FLAGS2, BDWELLRT                        ;signal dwell
  252.         movf    FREQR, w
  253.         movwf   DWELLTIMER                              ;reset dwell counter
  254.         btfss   FLAGS, COD5MODE                 ;test COD5 mode
  255.         goto    EndInterupt
  256.         bcf             STATUS, C
  257.         rrf             DWELLTIMER, f
  258.         addwf   DWELLTIMER, f
  259.         goto    EndInterupt
  260.  
  261. OffstateR2
  262.         decfsz  DWELLTIMER, f           ;count down dwell time to next pulse
  263.         goto    EndInterupt
  264.         bsf             FLAGS, PULSEONR         ;if dwell is done turn on outputs
  265.         bsf             STATUS, RP0             ;bank 1
  266.         bcf             TRISIO, TRIGGERR        ;and reset pulse time
  267.         bcf             STATUS, RP0             ;bank 0
  268.         movf    FREQR, w                        ;from frequency value
  269.         movwf   DWELLTIMER
  270.         btfss   FLAGS, COD5MODE                 ;test COD5 mode
  271.         goto    EndInterupt
  272.         bcf             STATUS, C
  273.         rrf             DWELLTIMER, f
  274.         addwf   DWELLTIMER, f
  275.         goto    EndInterupt
  276.  
  277. BurstDwellR
  278.         btfss   FLAGS, TRIGOUT
  279.         goto    CGBurstR
  280.         btfss   GPIO, TRIGGERR
  281.         goto    EndInterupt
  282.         goto    BurstResetR
  283.  
  284. CGBurstR
  285.         btfsc   GPIO, TRIGGERR
  286.         goto    EndInterupt
  287.  
  288. BurstResetR
  289.         bcf             FLAGS, PULSEONR         ;if dwell is done turn on outputs
  290.         bcf             FLAGS2, BDWELLRT
  291.         bcf             FLAGS2, BURSTONR
  292.  
  293.  
  294.  
  295.  
  296. EndInterupt
  297.         bcf             PIR1, TMR2IF
  298.  
  299.         movf    status_temp,w     ; retrieve copy of STATUS register
  300.         movwf   STATUS            ; restore pre-isr STATUS register contents
  301.         swapf   w_temp,f
  302.         swapf   w_temp,w          ; restore pre-isr W register contents
  303.         retfie                      ; return from interrupt
  304.  
  305.  
  306.  
  307. ;
  308. ;              HAY MUCHAS RUTINAS MAS AQUI PERO NO LAS PONGO PORQUE EL PROGRAMA ES LARGO Y NO LO VEO NECESARIO
  309. ;
  310.  
  311.  
  312.  
  313. main
  314.  
  315.         clrf    LEDActivado
  316.         clrf    DATOSEE
  317.         clrf    DIRECCIONEE
  318.         clrf    DESACTIVADO
  319.         clrf    TEMPFREE
  320.         clrf    TEMPLED3EE
  321.         clrf    TEMPLED3EEconta
  322.         clrf    TEMPLED4EE
  323.         clrf    TEMPLED4EEconta
  324.         clrf    HAYCAMBIO
  325.         clrf    TEMP
  326.         clrf    TEMPFastForward
  327.         clrf    TEMPFastRewind
  328.         clrf    TEMPFast
  329. ; --------------------------
  330.  
  331.         clrf    GPIO
  332.         clrf    FLAGS                           ;clear outputs and code status register
  333.         clrf    FLAGS2
  334.         movlw   0x07
  335.         movwf   CMCON0                          ;comparators off
  336.         bsf             STATUS, RP0                     ;bank 1
  337.         movlw   0x0F                            ;start with 0-3 inputs (ADC read)
  338.         movwf   TRISIO                          ;pin 0 & 1 & 5 out, all other inputs
  339.         movlw   0x51                            ;Fosc/16, pin 0 analog
  340.         movwf   ANSEL                           ;Right trigger is analog input
  341.         movlw   0x04
  342.         movwf   WPU                                     ;enable week pullups
  343.         bcf             OPTION_REG, 7           ;enable all week pullups
  344.         bcf             STATUS, RP0                     ;bank 0
  345.  
  346.         movlw   0x01                            ;Left just, Vdd, channel 0
  347.         movwf   ADCON0                          ;module on.
  348.         movlw   0x10
  349.         movwf   TEMP1
  350. Wait4ADC
  351.         decfsz  TEMP1, f
  352.         goto    Wait4ADC                        ;acquisition time
  353.         bsf             ADCON0, 1                       ;start ADC
  354.         btfsc   ADCON0, 1
  355.         goto    $-1                                     ;wait for conversion to be done
  356.         movlw   0x40                            ;about 0.5V from 2V ref
  357.         subwf   ADRESH, w                       ;if f > W, C=1
  358.         btfsc   STATUS, C                       ;ie- if trigger > 0.5V, then matrix
  359.         bsf             FLAGS, TRIGOUT          ;matrix config sources (output high)
  360.         bsf             STATUS, RP0                     ;bank 1
  361.         movlw   0x0C                            ;restore pin IO
  362.         movwf   TRISIO 
  363.         clrf    ANSEL                           ;all digital now
  364.         bcf             STATUS, RP0                     ;bank 0
  365.  
  366.         movlw   0x0A                            ;start with 10ms pulse width
  367.         movwf   LEDBLINK                        ;for the LEDs
  368. ;       movlw   FIRERATE1                       ;this will get overwritten,
  369.         movwf   PULSER                          ; but start with a default value
  370.         movwf   PULSEL
  371.         movwf   DWELLTIMER
  372.         movwf   DWELLTIMEL
  373.         movlw   0x05                            ;init burst rate
  374.         movwf   BURSTRATE
  375.         movwf   BURSTRight
  376.         movwf   BURSTLeft
  377.  
  378. ;       movf    EESTATE, w
  379.         movlw   0x00
  380.         movwf   DIRECCIONEE
  381.         call    ReadEE                          ;get state value
  382.         movwf   STATE
  383.  
  384.  
  385.         movlw   0x01
  386.         movwf   T2CON                           ;timer 2, prescale 1:4, no postscale
  387.         bsf             STATUS, RP0                     ;bank 1
  388.         movlw   0xFA
  389.         movwf   PR2                                     ;setup 1ms hardware interupt
  390.         bsf             PIE1, TMR2IE            ;enable timer2 interupt
  391.         bcf             STATUS, RP0                     ;bank 0
  392.         bsf             T2CON, TMR2ON           ;turn on timer2
  393.         movlw   0xC0
  394.         movwf   INTCON                          ;turn on interupts globally
  395.         goto    InitState                       ;get first fireratSTATE4e value
  396.  
  397.  
  398.  
  399.  
  400. ;******************** Y AHORA EL CODIGO DE LO QUE QUIERO HACER, QUE SE QUE LO ESTOY HACIENDO MAL, PERO NO SE QUE ***********************************************
  401. ;********************************* NO SE SI EL PROBLEMA ESTE EN ALGO RELACIONADO CON LAS INTERRUPCIONES  *******************************************************
  402.         btfss   STATE, LEFTACTIVE       ;is RF on?
  403.         goto    TestLeft
  404.  
  405. ActiveReloaded
  406.         btfss   FLAGS, TRIGOUT          ;controllertype
  407.         bcf             GPIO, TRIGGERL          ;determines
  408.         btfsc   FLAGS, TRIGOUT          ;output state
  409.         bsf             GPIO, TRIGGERL
  410.  
  411.         bcf             FLAGS, PULSEONL         ;10ms is over, clear flags and
  412.         bsf             STATUS, RP0                     ;bank 1
  413.         bsf             GPIO, TRIGGERL  ;tristate output
  414.         bcf             STATUS, RP0                     ;bank 0
  415. ;       call    Wait10ms
  416. ;       bsf             STATUS, RP0                     ;bank 1
  417. ;       bcf             GPIO, TRIGGERL  ;and reset pulse time
  418. ;       bcf             STATUS, RP0                     ;bank 0
  419.  
  420. DemoraActiveReloaded
  421.         movlw   0x64
  422.         movwf   BUTTONHOLD                      ;setup for 2 second hold
  423.         call    Wait10ms
  424.         decfsz  BUTTONHOLD, f          
  425.         goto    DemoraActiveReloaded
  426.  
  427.         bcf             FLAGS, PULSEONL         ;10ms is over, clear flags and
  428.         bsf             STATUS, RP0                     ;bank 1
  429.         bsf             GPIO, TRIGGERL  ;tristate output
  430.         bcf             STATUS, RP0                     ;bank 0
  431.  
  432.         call    Wait10ms
  433.         bsf             FLAGS, PULSEONL         ;if dwell is done turn on outputs
  434.         bsf             STATUS, RP0                     ;bank 1
  435.         bcf             GPIO, TRIGGERL  ;and reset pulse time
  436.         bcf             STATUS, RP0                     ;bank 0
« Última modificación: 30 de Mayo de 2011, 18:29:22 por sQs »

Desconectado tapi8

  • Colaborador
  • PIC24H
  • *****
  • Mensajes: 1506
Re: Hacer una interrupcion
« Respuesta #3 en: 01 de Junio de 2011, 12:55:16 »
Citar
Tal vez ya te enrede un poco pero te explico mas claro lo que necesito lograr:
- GP4 estara como salida unicamente
- Se hara la comparacion si GP4 esta activa la salida
- En caso de estarlo se hara otra comparacion, de si esta recibiendo señal GP1
- Y en caso que este alla recibido una señal, se hara una demora (por ejemplo 500 ms, esta yo la estare variando por medio de una variable) y se enviara una señal al mismo puerto GP1 (digamos como un parpadeo muy rapido).

Bien para hacer esto no necesitas interrupcion, ni tantos reg. de RAM.

Miras si GP4 esta a 1

btfss   GP4
goto   $-1   ; si no esta a 1 estara aqui hasta que se ponga a 1.

Eso si, si es una salida, tendras que ponerla tu a 1, esto o yo no lo entendi bien o tu no lo tienes muy claro.


btfss   GP4
goto   $-1   ; si no esta a 1 estara aqui hasta que se ponga a 1.
btfss   GP1  ; miramos si GP1 es 1
goto   $-1    ; o $-4 si quieres que empiece

Ya estan las dos condiciones para que se active GP1, cambias de banco a banco 1 para poner GP1 como salida, haces una demora de 500ms, la llamas y cuando retorne haces

bsf  GP1   ; enciendes LED
call  DEMORA; aqui puedes usar la de 500ms o poner otra mas pequeña de 100 o 200ms
bcf   GP1      ; apagas LED
call   DEMORA

Repites este ciclo las veces que quieras y mas o menos ya estaria.

Creo que en ese programa que pones no activas las interrupcione en el reg. INTCON, tienes que habilitar GIE y despues las interrupciones que quieras activar, igual estoy equivocado pero no vi que lo hicieras.