viernes, 4 de enero de 2013

ADC 12F675 ASM

Interfas.asm
;GP0 AN0
;GP1 TX
;GP2 RX
;GP3 
;GP4 OSC |Cristal de 4Mhz
;GP5 OSC |

list p=pic12f675
#include "p12f675.inc"

__config        _XT_OSC & _PWRTE_ON & _WDT_OFF & _CP_OFF & _BODEN_ON  & _MCLRE_OFF


#define tx GPIO,1
#define rx GPIO,2


 cblock    0x20
  rx_reg
  tx_reg
  xcount
  del
  dato_adc
 endc

 org     0x0
 goto      inicio
;----------------------------------------------------------------------------            
 org     0x5
;----------------------------------------------------------------------------         
inicio bsf STATUS,RP0 ; banco 1
 movlw b'00001101' ;
 movwf TRISIO  ;
 movlw b'00010001'
 movwf ANSEL
 bcf STATUS,RP0

 movlw   b'00000001'
 movwf ADCON0

 bsf ADCON0,1

ADC_esp btfss ADCON0,1
 goto ADC_esp

;------------------------
;    Bucle principal
;------------------------ 
bucle     movf  ADRESH,w
   call Serial_Tx
   bsf ADCON0,1
   goto   bucle
 
;-------------------------  
Serial_Rx
   clrf   rx_reg
Check   btfsc  rx
   goto  Check
   call   Delay2
Rcvr   movlw  .8
   movwf  xcount
Rnext   bcf  STATUS,C
   btfsc  rx
   bsf  STATUS,C
   rrf  rx_reg, F
   call  Delay1
   decfsz xcount, F
   goto  Rnext 
   retlw  0

Serial_Tx
  movwf tx_reg
  movlw 8
  movwf xcount
  bcf tx
  call Delay1
Xnext  bcf tx
  bcf STATUS,C
  rrf tx_reg, F
  btfsc STATUS,C
  bsf tx
  call Delay1
  decfsz xcount, F
  goto Xnext
  bsf tx
  call Delay1
  retlw 0


Delay2   movlw   .03    ;.248:1200, .41:2400, .19:4800, .08:9600, .03:19200
   movwf   del     ;.01:34800
Redo2     nop
   nop
   decfsz del, F
   goto  Redo2
   retlw  0

Delay1   movlw  .08    ;.166:1200, .83:2400, .41:4800, .19:9600, .08:19200
   movwf  del     ;.03:34800
Redo   nop
   nop
   decfsz del, F
   goto  Redo
   retlw  0

;----------------------------
end

IRC

#freenode->#usljujuy

Seguidores

Eventos n_n

Tira Ecol Nano,Bilo y Luca