tecnico
#include ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_ON & _CPD_OFF
;**** Definicion de variables ****
DATA_RS232 equ 0x31 ; Dato recibido desde PC.-
Flags equ 0x32 ;
;**** Definiciones para el ensamblador ****
#DEFINE Kbhit Flags,0 ; Indicasi se ha recibido algun dato.-
;**** Definición de macros ****
; Se envia la data de un registro a PC.-
Putreg macro Registro
movfw Registro
call RS232_EnviaDato
endm
; Se envia un literal a PC.-
Putc macro ACKII
movlw ACKII
call RS232_EnviaDato
endm
;-------Configuraci?n de puertos-------
tx_port equ PORTB ; Puerto de tranmisión
tx_pin equ 0x1 ; Pin de transmisiónrx_port equ PORTB ; Puerto de recepción
rx_pin equ 0x0 ; Pin de recepción
data_tx equ 0x20 ; Datos a enviar
data_rx equ 0x21 ; Datos recibidos
count_p equ 0x22 ; Contador para el numero de bits
flag equ 0x23
W_Temp equ 0x24
STATUS_Temp equ 0x25
count_gps equ 0x26
count_gps2 equ 0x27
d1 equ 0x28
d2 equ 0x29
d3 equ 0x30
ORG 0x00
GOTO inicio
ORG 0X04bsf PORTB,6
bcf STATUS,RP0 ; Banco 1
;recomdecion de microchip para la ISR al enpesar la interupcion--------------------
movwf W_Temp ; Copiamos W a un registro Temporario.-
swapf STATUS, W ;Invertimos los nibles del registro STATUS.-
movwf STATUS_Temp ; Guardamos STATUS en un registro temporal.-
;---------------------------------------------------------------------------------movlw 0x08
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
BTFSC flag,0
goto verificausart ;SI ES POR INT TMR0
BTFSC PORTB,0
goto verificausart
goto recv_b ;SI ES POR INT RB0
verificausart
btfss PIR1,RCIF ; Consultamos si es Usart.rx-
goto rs
goto ISR
inicio
BSF STATUS,5 ;ENTRAMOS ALBANK1
MOVLW .1 ;cargo w con 1
MOVWF TRISB ;PORTB,7-1 SALIDA Y PORTB,0 ENTRADA
movlw 0x80
movwf TRISC ; Configuo pines para Usart.-
movlw 0x04
movwf TXSTA ; Configura modo asincrono, baud rate de alta velocidad
movlw 0x19 ; Configura velocidad a 9600 baudios con cristal de 4 Mhz
movwf SPBRG
;bsf PIE1,TXIE; Habilitainterrupcion de puerto serie para transmision
bsf PIE1,RCIE ; Habilita interrupcion de puerto serie para recepcion
bsf INTCON,GIE ; Habilitacion general interrupciones
bsf INTCON,PEIE ; Habilitacion de interrupciones por perifericos
bsf TXSTA,TXEN ; Habilita transmision
; Activar recepcion, transmision.-
MOVLW .3 ; cargo w con 011
MOVWF OPTION_REG ; el Divisor = 256
BCFSTATUS,5 ;ENTRAMOS AL BANK0
bsf RCSTA,SPEN ; Habilitacion puerto serie
bsf RCSTA,CREN ; Habilita recepcion
bcf Kbhit ; Limpiamos bandera.
CLRF PORTB ; limpiamos PORTB
CLRF PORTC
CLRF flag
nada
CALL GPS ; VA A LEER LA TRAMA GPS SI PASA 1 SEGUNDO RETORNA CON UN ERROR DE SIN CONEXION GPS ;O SINO REGRESA CON UN DATO VALIDOgoto nada ; VOY A LA ETIQUETA nada
GPS;ESTO ES PARA CARGAR EL TIEMPO DE 1 SEGUNDO;
movlw 0x08 ;
movwf d1 ;
movlw 0x2F ;
movwf d2 ;
movlw 0x03 ;
movwf d3 ;
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
BSF INTCON,INTE ;ACTIVAMOS GEI,INTE Y LIMPIAMOS BANDERAS
bsf flag,1
LEEGPS
Delay_0
btfss Kbhit
goto $+2
CALL ENVIADATOBTFSC flag,1 ;DESPUES DE LEER TODOS LOS DATOS VA A COPIAR EL DATO COMPLETO A PORTC CON LA ETIQUETA COPIADATO
goto $+2
call copiadato
;ESTO DEMORA 1 SEGUNDO>>>>>>>>>>>>>>
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;3 cycles
goto $+1
nop
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
BCF INTCON,INTE ;ACTIVAMOS GEI,INTE Y LIMPIAMOS...
Regístrate para leer el documento completo.