El conversor análogo a digital es un dispositivo que me permite digitalizar señales, en este caso vamos a medir el voltaje por el pin AN1 y si es mayor a 2.5 voltios activamos el LED conectado en GP2.
Circuito
QR para el celular
Código fuente
LIST P=12F675
INCLUDE P12F675.INC
ERRORLEVEL -302
; Trabajamos con un oscilador interno a 4Mhz
__CONFIG _CPD_OFF & _CP_OFF & _BODEN_ON & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
CBLOCK 0X20
d1, d2, VALOR
ENDC
ORG 00
GOTO INICIO
RET10MS ;9998 cycles
movlw 0xCF
movwf d1
movlw 0x08
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0
;2 cycles
goto $+1
RETURN
INICIO NOP
CLRF GPIO
MOVLW B'00000111' ; 07H Configuro GP1, GP2, GP3 como pines
MOVWF CMCON ; digitales y no del comparador del micro
BANKSEL OSCCAL
CALL 3FFH ; Obtengo el valor de calibracion del oscilador
MOVWF OSCCAL ; y lo calibro con el OSCCAL
BANKSEL ADCON0 ; Configuro el AD
MOVLW B'00000101' ; 7 6 5 4 3 2 1 0
MOVWF ADCON0 ; justifico derecha, no uso, no uso, Vdd, canal AN1, GO, ad ON
BANKSEL ANSEL
MOVLW .2
MOVWF ANSEL ;CONFIGURO GP1/AN1 COMO ENTRADA ANALOGA
MOVLW .2
MOVWF TRISIO
BANKSEL GPIO
CICLO CALL RET10MS
BSF ADCON0,GO ; Inicio conversion
BTFSS ADCON0,GO ; Espero a que finalice la conversion
GOTO $-1
; Conversion finalizada
BANKSEL ADRESH
MOVF ADRESH,W ; Paso el dato tomado por el conversor a W
BANKSEL VALOR
MOVWF VALOR ; Almaceno el dato
MOVLW .128 ; pregunto si el dato es mayor a .128
SUBWF VALOR,W
BTFSS STATUS,C
GOTO MENOR ; Si el dato es Menor
GOTO MAYOR ; Si el dato es Mayor
MENOR BCF GPIO,2
BSF GPIO,0
GOTO CICLO
MAYOR BSF GPIO,2
BCF GPIO,0
GOTO CICLO
END
Copyright 2012 edwtron
Este DOCUMENTO es un DOCUMENTO LIBRE, usted puede redistribuirlo y/o modificarlo bajo los terminos de la GNU FDL tal y como es publicada por la fundacion de software libre; bajo la version 1.3 de la licencia, o una version superior.
Leer la licencia GNU gpl para mas detalles.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
Translate, Traductor
Mostrando entradas con la etiqueta 12F675. Mostrar todas las entradas
Mostrando entradas con la etiqueta 12F675. Mostrar todas las entradas
martes, 12 de junio de 2012
jueves, 7 de junio de 2012
Plantilla PIC 12F675
Plantilla para el microcontrolador 12F675
Un microcontrolador de 8 pines, 6 de ellos disponibles para entrada y salida, 1024 palabras de 14 bit's cada una, frecuencia máxima del oscilador igual a 20 MHz, oscilador interno de 4 MHz, característica interesante ya que no necesitaremos cristal, lo que nos ahorra dos pines, 128 Bytes de EEPROM, 64 Bytes de RAM.
Importante:
Estamos acostumbrados a que los puertos de los PIC's son llamados PORTx, en los micros de 8 pines son llamados GPIO y los pines GP0, GP1, GP2, GP3, GP4 y GP5
Plantilla
LIST P=12F675
INCLUDE P12F675.INC
ERRORLEVEL -302
; Trabajamos con un oscilador interno a 4Mhz
__CONFIG _CPD_OFF & _CP_OFF & _BODEN_ON & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
CBLOCK 0X20
ENDC
ORG 00
GOTO CONFIGURA
CONFIGURA NOP
CLRF GPIO
MOVLW B'00000111' ; 07H Configuro GP1, GP2, GP3 como pines, no uso el comparador
MOVWF CMCON ; digitales
BANKSEL OSCCAL
CALL 3FFH ; Obtengo el valor de calibracion del oscilador
MOVWF OSCCAL
CLRF TRISIO
BANKSEL GPIO
INICIO
GOTO INICIO
END
; *
; * Copyright 2012 EDWTRON
; *
; * Este rpograma es software libre; usted puede redistribuirlo y/o modificarlo
; * bajo los terminos de la GNU licencia publica general tal y como es publicada
; * por la fundacion de software libre; bajo la version 2 de la licencia, o
; * una version superior.
; * Leer la licencia GNU gpl para mas detalles.
; * This program is free software; you can redistribute it and/or modify
; * it under the terms of the GNU General Public License as published by
; * the Free Software Foundation; either version 2 of the License, or
; * (at your option) any later version.
; *
; * This program is distributed in the hope that it will be useful,
; * but WITHOUT ANY WARRANTY; without even the implied warranty of
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; * GNU General Public License for more details.
; *
; * You should have received a copy of the GNU General Public License
; * along with this program; if not, write to the Free Software
; * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
; * MA 02110-1301, USA.
; *
Copyright 2012 edwtron
Este DOCUMENTO es un DOCUMENTO LIBRE, usted puede redistribuirlo y/o modificarlo bajo los terminos de la GNU FDL tal y como es publicada por la fundacion de software libre; bajo la version 1.3 de la licencia, o una version superior.
Leer la licencia GNU gpl para mas detalles.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
Un microcontrolador de 8 pines, 6 de ellos disponibles para entrada y salida, 1024 palabras de 14 bit's cada una, frecuencia máxima del oscilador igual a 20 MHz, oscilador interno de 4 MHz, característica interesante ya que no necesitaremos cristal, lo que nos ahorra dos pines, 128 Bytes de EEPROM, 64 Bytes de RAM.
Importante:
Estamos acostumbrados a que los puertos de los PIC's son llamados PORTx, en los micros de 8 pines son llamados GPIO y los pines GP0, GP1, GP2, GP3, GP4 y GP5
Plantilla
LIST P=12F675
INCLUDE P12F675.INC
ERRORLEVEL -302
; Trabajamos con un oscilador interno a 4Mhz
__CONFIG _CPD_OFF & _CP_OFF & _BODEN_ON & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
CBLOCK 0X20
ENDC
ORG 00
GOTO CONFIGURA
CONFIGURA NOP
CLRF GPIO
MOVLW B'00000111' ; 07H Configuro GP1, GP2, GP3 como pines, no uso el comparador
MOVWF CMCON ; digitales
BANKSEL OSCCAL
CALL 3FFH ; Obtengo el valor de calibracion del oscilador
MOVWF OSCCAL
CLRF TRISIO
BANKSEL GPIO
INICIO
GOTO INICIO
END
; *
; * Copyright 2012 EDWTRON
; *
; * Este rpograma es software libre; usted puede redistribuirlo y/o modificarlo
; * bajo los terminos de la GNU licencia publica general tal y como es publicada
; * por la fundacion de software libre; bajo la version 2 de la licencia, o
; * una version superior.
; * Leer la licencia GNU gpl para mas detalles.
; * This program is free software; you can redistribute it and/or modify
; * it under the terms of the GNU General Public License as published by
; * the Free Software Foundation; either version 2 of the License, or
; * (at your option) any later version.
; *
; * This program is distributed in the hope that it will be useful,
; * but WITHOUT ANY WARRANTY; without even the implied warranty of
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; * GNU General Public License for more details.
; *
; * You should have received a copy of the GNU General Public License
; * along with this program; if not, write to the Free Software
; * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
; * MA 02110-1301, USA.
; *
Copyright 2012 edwtron
Este DOCUMENTO es un DOCUMENTO LIBRE, usted puede redistribuirlo y/o modificarlo bajo los terminos de la GNU FDL tal y como es publicada por la fundacion de software libre; bajo la version 1.3 de la licencia, o una version superior.
Leer la licencia GNU gpl para mas detalles.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
Etiquetas:
12F675,
assembler,
bit's,
circuito integrado,
ensamblador,
memoria,
microchip,
microcontrolador,
MPLAB IDE,
plantilla
Suscribirse a:
Entradas (Atom)