Autor Tema: interrupcion externa con pic 12f675  (Leído 4201 veces)

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

Desconectado villellaf

  • PIC10
  • *
  • Mensajes: 3
interrupcion externa con pic 12f675
« en: 06 de Mayo de 2011, 21:52:29 »
Estimados :
estoy empezando a usar el 12f675 arme una rutina para encender y apagar un led y funciona perfecto con int externa GPIO2. pero se dispara casi en VCC.
me parece extraño que no se dispare a aprox en 0.3*VCC.   que me falta configurar?

Gracias

   list p=12F675 ; list directive to define processor
   #include <p12f675.inc> ; processor specific variable definitions

   __CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

;*****Set up the Constants****

Del0          equ 20h
PDel1         equ 21h
w_temp         equ 22h
pulsew         equ 23h
status_temp      equ 24h
d05_1         equ 25h
exp_time      equ 26h
flag         equ 27h
var         equ 28h







      ORG     0x000             ; processor reset vector
        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
      bcf     STATUS,RP0        ; ensure file register bank set to 0
      movwf   status_temp       ; save off contents of STATUS register
;========================cuenta mientras PORTB esta en 1========================
      
      call   delay08
      
tst0   btfss   GPIO,2   ;2
      goto   ENDINTR

      btfss   GPIO,5
      goto   uno
      bcf      GPIO,5
      GOTO   ENDINTR
uno    bsf      GPIO,5
   




      
      
ENDINTR
;=======================================================================
       bcf     STATUS,RP0        ; ensure file register bank set to 0
      movf    status_temp,w     ; retrieve copy of STATUS register
      movwf   STATUS            ; restore pre-isr STATUS register contents
      swapf   w_temp,f
      swapf   w_temp,w          ; restore pre-isr W register contents
      

      BCF      INTCON,INTF
      retfie                    ; return from interrupt



Main

;****Set up the port****
      bcf    STATUS,RP0 ;Bank 0
      clrf    GPIO ;Init GPIO
      movlw    07h ;Set GP<2:0> to
      movwf    CMCON ;digital IO
      clrf   CMCON
      bsf    STATUS,RP0 ;Bank 1
      clrf    ANSEL ;Digital I/O
      clrf   TRISIO
      movlw    0ch ;Set GP "xx001100"
      movwf    TRISIO ;
;****Set up the INT****

      bcf    STATUS,RP0 ;Bank 0
      movlw    90h
      movwf   INTCON

      bsf    STATUS,RP0 ;Bank 1
      
      movlw   .192
      movwf   OPTION_REG


      
Start   
      

Start1      
      
         goto    Start1

;=======================================================================         
delay08     movlw     .198    ; .248 set number of repetitions
           movwf     Del0     ; 1 |
Loop0       clrwdt              ; 1 clear watchdog
           decfsz    Del0,1  ; 1 + (1) is the time over?
           goto      Loop0    ; 2 no, loop
DelL1      goto      DelL2         ; 2 cycles delay
DelL2      clrwdt              ; 1 cycle delay
           return              ; 2+2 Done





;****End of the program****

   end
« Última modificación: 07 de Mayo de 2011, 08:06:16 por villellaf »

Desconectado Fer_TACA

  • Moderadores
  • DsPIC33
  • *****
  • Mensajes: 4154
Re: interrupcion externa con pic 12f675
« Respuesta #1 en: 07 de Mayo de 2011, 07:50:02 »
Pues como no sabemos como lo tienes configurado poco podremos hacer.
Lo mas logico es que postees lo que tengas realizado y podremos echar un vistazo y ver que le falta, sobra o hya que cambiar.


F.
Todos los días se aprende algo nuevo.

Desconectado villellaf

  • PIC10
  • *
  • Mensajes: 3
Re: interrupcion externa con pic 12f675
« Respuesta #2 en: 07 de Mayo de 2011, 08:05:36 »
les adjunto el asm lo pruebo y funciona ok pero dispara casi a la tension de fuente

   list p=12F675 ; list directive to define processor
   #include <p12f675.inc> ; processor specific variable definitions

   __CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT

;*****Set up the Constants****

Del0          equ 20h
PDel1         equ 21h
w_temp         equ 22h
pulsew         equ 23h
status_temp      equ 24h
d05_1         equ 25h
exp_time      equ 26h
flag         equ 27h
var         equ 28h







      ORG     0x000             ; processor reset vector
        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
      bcf     STATUS,RP0        ; ensure file register bank set to 0
      movwf   status_temp       ; save off contents of STATUS register
;========================cuenta mientras PORTB esta en 1========================
      
      call   delay08
      
tst0   btfss   GPIO,2   ;2
      goto   ENDINTR

      btfss   GPIO,5
      goto   uno
      bcf      GPIO,5
      GOTO   ENDINTR
uno    bsf      GPIO,5
   




      
      
ENDINTR
;=======================================================================
       bcf     STATUS,RP0        ; ensure file register bank set to 0
      movf    status_temp,w     ; retrieve copy of STATUS register
      movwf   STATUS            ; restore pre-isr STATUS register contents
      swapf   w_temp,f
      swapf   w_temp,w          ; restore pre-isr W register contents
      

      BCF      INTCON,INTF
      retfie                    ; return from interrupt



Main

;****Set up the port****
      bcf    STATUS,RP0 ;Bank 0
      clrf    GPIO ;Init GPIO
      movlw    07h ;Set GP<2:0> to
      movwf    CMCON ;digital IO
      clrf   CMCON
      bsf    STATUS,RP0 ;Bank 1
      clrf    ANSEL ;Digital I/O
      clrf   TRISIO
      movlw    0ch ;Set GP "xx001100"
      movwf    TRISIO ;
;****Set up the INT****

      bcf    STATUS,RP0 ;Bank 0
      movlw    90h
      movwf   INTCON

      bsf    STATUS,RP0 ;Bank 1
      
      movlw   .192
      movwf   OPTION_REG


      
Start   
      

Start1      
      
         goto    Start1

;=======================================================================         
delay08     movlw     .198    ; .248 set number of repetitions
           movwf     Del0     ; 1 |
Loop0       clrwdt              ; 1 clear watchdog
           decfsz    Del0,1  ; 1 + (1) is the time over?
           goto      Loop0    ; 2 no, loop
DelL1      goto      DelL2         ; 2 cycles delay
DelL2      clrwdt              ; 1 cycle delay
           return              ; 2+2 Done





;****End of the program****

   end