Buenas tardes, espero puedan ayudarme, soy nuevo en esto de los PICs en ensamblador y realice un programa el cual tiene que hacer lo siguiente:
Configurar el TMR0 a 100ms, configurar el oscilador interno a 2MHz, luego hay que hacer una secuencia que encienda y apague un led en 300 ms, luego por medio de dos bits de entrada hay que multiplicar el tiempo x1,x2,x3 y x4, mi código es el siguiente, mis bits de entrada son GPIO1 y GPIO2, el bit de salida es GPIO0, la configuración del TMR0 y el oscilador ya esta hecha solo que no logro hacer que se multiplique el tiempo a la hora de meter las distintas configuraciones de los bits de entrada, espero haber hecho entender, gracias!!
PROCESSOR 12F675
; CONFIG
CONFIG FOSC = INTRCIO ; Oscillator Selection bits (INTOSC oscillator: I/O function on GP4/OSC2/CLKOUT pin, I/O function on GP5/OSC1/CLKIN)
CONFIG WDTE = OFF ; Watchdog Timer Enable bit (WDT disabled)
CONFIG PWRTE = ON ; Power-Up Timer Enable bit (PWRT enabled)
CONFIG MCLRE = ON ; GP3/MCLR pin function select (GP3/MCLR pin function is MCLR)
CONFIG BOREN = ON ; Brown-out Detect Enable bit (BOD enabled)
CONFIG CP = OFF ; Code Protection bit (Program Memory code protection is disabled)
CONFIG CPD = OFF ; Data Code Protection bit (Data memory code protection is disabled)
// config statements should precede project file includes.
#include <xc.inc>
psect barfunc,abs,class=CODE,delta=2
conteo equ 0x20
time equ 0x21
ORG 0 ;Vector de reset
goto START
ORG 5 ;Incio de la memoria de programa
;Configuraciones de inicio
START: banksel TRISIO
movlw 0x06 ;configura los puertos 0000 0110
movwf TRISIO
clrf ANSEL ;puertos digitales
banksel GPIO
clrf GPIO
call CONF
;Programa principal
LOOP: bsf GPIO,0 ;encender el LED
call ENTRADAS ;leer entradas
call TIEMPO ;escoger tiempo
movwf time
call DELAY
bcf GPIO,0 ;apagar el LED
call ENTRADAS ;leer entradas
call TIEMPO ;escoger tiempo
movwf time
call DELAY
goto LOOP
ENTRADAS: movf GPIO,w ;leer entradas
andlw 0x0F ;mascara
return
;Escoger tiempo
TIEMPO: addwf PCL,f
retlw 0x03 ;00-300ms
retlw 0x06 ;01-600ms
retlw 0x09 ;10-900ms
retlw 0x0C ;11-1200ms
;subrutina de timer
DELAY: movf time,w
movwf conteo
call RETARDO
return
RETARDO: bcf INTCON,2 ;limpia bandera de sobreflujo
movlw 0x3C ;carga 100ms
movwf TMR0
RETARDO_1: btfss INTCON,2 ;checa la bandera de sobreflujo y salta si 1
goto RETARDO_1
decfsz conteo,f
goto RETARDO
return
;configuracion del timer
CONF: banksel OPTION_REG
movlw 0x87
movwf OPTION_REG
banksel GPIO
return
END