Autor Tema: interrupciones en asm con PBP, me ayudan?  (Leído 1666 veces)

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

Desconectado super_2005

  • PIC10
  • *
  • Mensajes: 3
interrupciones en asm con PBP, me ayudan?
« en: 10 de Febrero de 2005, 19:05:00 »
hola,
tengo problemas  con el 16f628A y su interrupcion por RX,
simplememte quiero que al recibir un char por RX se genere una int
que almacene el char recibido en una var para luego reenvier dicho char.
Alguien podria echar un vistazo al codigo para ver que estoy haciendo mal?

saludos y gracias desde ya!

 


define  INTHAND myint

cont var word
B1      var     byte
temp_w var byte
temp_s var byte
goto init
"----------------------------------------------------- Interrupt handler
asm
myint   MOVWF _temp_w          ; save w register
        MOVF STATUS, W       ; W = STATUS
        MOVWF _temp_s          ; save STATUS register
        ; Check if we"re called because of receiving a character
       btfss PIR1,RCIF
       goto end_isr   ; Interrupt came from something else
      movf RCREG,W   ;Retrieve the received character and store it in tempchar
   movwf _B1
end_isr
   BCF PIR1, RCIF   ; clear the RCIF flag bit
   MOVF  _temp_s, W ; Put STATUS and W back where they belong
          MOVWF STATUS
          SWAPF _temp_w, F
          SWAPF _temp_w, W
          RETFIE
endasm
"------------------------------------------------- end interrupt
init:
"--config pins------------------------------------
asm
        movlw 7
       movwf CMCON      ; CMCON=7 set comperators off
endasm
TRISa = %00000000 "  PORTa outputs
trisb=  %00000011  " rb1,rb0 inputs

"--config interrupts--------------------------------
INTCON = %10000000   " Enable  interrupts    
PIE1=  %00100000   "  int  rx enabled  

"---Initialize USART--------------------------------                            
        "SPBRG = 25              " Set baud rate to 2400
        SPBRG = 12              " Set baud rate to 4800
        RCSTA = %10010000       " Enable serial port and continuous receive
        TXSTA = %00110000       " Enable transmit and asynchronous mode

"---------------------------------------------------
porta.1  =1        " Turn on LED connected to PORTa.1
cont=0
b1=0

" ------------------------------------------------- main
loop:  

 If B1 > 0 Then
           Gosub charout           " Send character to serial output
 endif
 
Goto loop      
"--------------------------------------------   subs

" Subroutine to send a character to USART transmitter
charout:
If PIR1.4 = 0 Then charout     " Wait for transmit register empty

        TXREG = B1              " Send character to transmit register
        b1=0
Return                  " Go back to caller
End
 


Desconectado RGL

  • Colaborador
  • PIC24F
  • *****
  • Mensajes: 634
RE: interrupciones en asm con PBP, me ayudan?
« Respuesta #1 en: 12 de Febrero de 2005, 05:12:00 »
Busca un post de Abago en este foro que se lo curró mucho y está bastante explicado.

Saludos.
Ricky

Desconectado RALF2

  • Moderador Local
  • PIC24H
  • *****
  • Mensajes: 2062
RE: interrupciones en asm con PBP, me ayudan?
« Respuesta #2 en: 28 de Febrero de 2005, 01:57:00 »
Hola super_2005!
Mira en el libro de angulo aparese una aplicacion, muy buena referente a las interrupciones por el puerto serial, pero en asm. Seria cosa facil adaptarla al pbp yo la probe y funciona muy bien.

Sino encuentras el libro te la puedo enviar si la necesitas!

Saludos!


 

anything