;------------------------------------------------------------
; Código assembler generado por Niple V5.2.0
; Proyecto: RS232
; Autor: 
; Fecha: 01/12/2009
; PIC: 16F84A
; Velocidad de reloj: 4 Mhz
; Descripcion: 
;------------------------------------------------------------


 LIST    P=PIC16F84A


_XT_OSC               equ  0x3FFD
_WDT_OFF              equ  0x3FFB
_PWRTE_ON             equ  0x3FF7
_CP_OFF               equ  0x3FFF

 __config _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF


;------------------------------------------------------------
;                  Declaración de Registros
;------------------------------------------------------------
w                     equ  0x0000
status                equ  0x0003
porta                 equ  0x0005
pclath                equ  0x000a
contador              equ  0x000d
_np_temp1             equ  0x000e
_np_temp2             equ  0x000f
_np_temp3             equ  0x0010
_np_rs232_t           equ  0x0011
_np_rs232_t1          equ  0x0012
_np_config_interrup   equ  0x0013
_np_tiempo            equ  0x0015
_np_tiempo1           equ  0x0017
_np_tiempo2           equ  0x0018
_np_tiempo3           equ  0x0019
trisa                 equ  0x0085


;------------------------------------------------------------
;                  Declaración de Bits
;------------------------------------------------------------
c                     equ  0   ;carry / borrow bit
rp0                   equ  5   ;registrer bank select bit
rp1                   equ  6   ;registrer bank select bit
z                     equ  2   ;bit cero


;------------------------------------------------------------
;                        Inicio
;------------------------------------------------------------

reset   org 0
   goto paso2


;------------------------------------------------------------
;                      programa principal
;------------------------------------------------------------
paso2
   movlw b'00000000'                ;configurar el puerto a como xxxsssss
   bsf status,rp0                   ;cambiar a banco 1
   movwf trisa
   movlw 0x41
   bcf status,rp0                   ;cambiar a banco 0
   movwf contador
paso4
   movf contador,w                  ;enviar el dato contador
   movwf _np_temp1
   call rs232_ta0_4800
   movlw .1                         ;temporizador 1 seg
   call tiempo_1_255_mega_c

   incf contador,1                  ;contador = contador + 1
   goto paso4                       ;cierra el ciclo


;------------------------------------------------------------
;                  Declaración de Subrutinas
;------------------------------------------------------------

rs232_ta0_4800
   ;enviar un dato rs232 por porta,0 (por codigo)
   ;_np_temp1 = dato a enviar
   ;_np_temp2 = contador de bits
   movlw .8
   bcf status,rp0                   ;cambiar a banco 0
   movwf _np_temp2
   bcf porta,0
   call rs232_4800_bit
rs232_ta0_4800_tx_otro
   bcf porta,0
   bcf status,c
   rrf _np_temp1,1
   btfsc status,c
   bsf porta,0
   call rs232_4800_bit
   decfsz _np_temp2,1
   goto rs232_ta0_4800_tx_otro
   bsf porta,0
   call rs232_4800_bit
   return


tiempo_1_255_mega_c
   movwf _np_tiempo
   goto tiempo_1_255_mega_c_1
tiempo_1_255_mega_c_bucle2
   nop
   nop
   nop
   nop
   nop
   nop
   nop
tiempo_1_255_mega_c_1
   movlw .10
   movwf _np_tiempo1
tiempo_1_255_mega_c_bucle1
   nop
   nop
   movlw .99
   movwf _np_tiempo2
tiempo_1_255_mega_c_bucle0
   nop
   nop
   nop
   movlw .200
   movwf _np_tiempo3
tiempo_1_255_mega_c_bucle
   nop
   nop
   decfsz _np_tiempo3,1
   goto tiempo_1_255_mega_c_bucle
   nop
   nop
   nop
   decfsz _np_tiempo2,1
   goto tiempo_1_255_mega_c_bucle0
   nop
   nop
   nop
   decfsz _np_tiempo1,1
   goto tiempo_1_255_mega_c_bucle1
   decfsz _np_tiempo,1
   goto tiempo_1_255_mega_c_bucle2
   return


rs232_4800_bit
   movlw .20
   movwf _np_rs232_t
   goto rs232_4800_bit_2
rs232_4800_bit_bucle
   nop
   nop
   nop
   nop
   nop
   nop
   nop
rs232_4800_bit_2
   decfsz _np_rs232_t,1
   goto rs232_4800_bit_bucle
   nop
   nop
   nop
   return
rs232_4800_mbit
   movlw .10
   movwf _np_rs232_t
   goto rs232_4800_mbit_2
rs232_4800_mbit_bucle
   nop
   nop
   nop
   nop
   nop
   nop
   nop
rs232_4800_mbit_2
   decfsz _np_rs232_t,1
   goto rs232_4800_mbit_bucle
   nop
   return

 End