;==========================
;Programa generador de PWM
;para controlar el color rojo
;==========================
list p=16F628A
movlw 00h
movwf 0Bh
clrf 05h
clrf 06h
bsf 03h,05h
movlw 00h
movwf 86h
movlw 0FFh
movwf 92h ;inicializa CCP1 (registro PR2)
bcf 03h,05h
movlw 05h
movwf 12h ;postscale 1:1, prescala 4, timer 2 fijado (registro T2CON)
movlw 0Fh
movwf 17h ;inicializa CCP1CON (PWM)
clrf 05h ;secuencia para deshabilitar
movlw 07h ;operaciones de comparación en PORTA
movwf 1Fh ;y habilitar funciones I/O (registro CMCON)
run
movlw 02h
movwf 27h
;============================
;Secuencia para diferentes
;intensidades de color rojo
;a una velocidad baja
;============================
one
movlw 01h ;al enviarle diferentes
movwf 15h ;valores al registro CCPR1L
call delay2 ;obtenemos diferentes
bcf 17h,04h ;anchos de pulso
bcf 17h,05h ;y por ende diferentes
movlw 01h ;intensidades del color
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 075h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 75h
movwf 15h
call delay2
movlw 75h
movwf 15h
call delay2
movlw 75h
movwf 15h
call delay2
decfsz 27h,01h
goto one
movlw 05h
movwf 27h
;============================
;Secuencia para diferentes
;intensidades de color rojo
;esta vez a una velocidad
;un poco más rápida
;============================
three
movlw 01h
movwf 15h
call delay3
bcf 17h,04h
bcf 17h,05h
movlw 01h
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 075h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
decfsz 27h,01h
goto three
movlw 02h
movwf 27h
;============================
;Secuencia para un difuminado
;del color rojo
;============================
two
movlw 0FFh
movwf 25h
movwf 15h
down
decf 25h,01h
movf 25h,00h
movwf 15h
call delay
movf 15h,00h
xorlw 0FFh
bcf 17h,04h
bcf 17h,05h
btfss 03h,02h
goto down
up
incf 25h,01h
movf 25h,00h
movwf 15h
call delay
movf 15h,00h
xorlw 0FFh
bsf 17h,04h
bsf 17h,05h
btfss 03h,02h
goto up
decfsz 27h,01h
goto two
goto run
;============================
;GP DELAY
;============================
delay
movlw 07Fh
movwf 020h
w6
movlw 0ffh
movwf 021h
w7
decfsz 021h, 01h
goto w7
decfsz 020h, 01h
goto w6
return
delay2
movlw 09h
movwf 20h
w8
movlw 0ffh
movwf 21h
w9
movlw 0FFh
movwf 22h
w9.1
decfsz 22h,01h
goto w9.1
decfsz 21h, 01h
goto w9
decfsz 20h, 01h
goto w8
return
delay3
movlw 0F1h
movwf 020h
w10
movlw 0ffh
movwf 021h
w11
decfsz 021h, 01h
goto w11
decfsz 020h, 01h
goto w10
return
end
;==========================
;Programa generador de PWM
;para controlar el color verde
;==========================
list p=16F628A
movlw 00h
movwf 0Bh
clrf 05h
clrf 06h
bsf 03h,05h
movlw 00h
movwf 86h
movlw 0FFh
movwf 92h ;inicializa CCP1 (registro PR2)
bcf 03h,05h
movlw 05h
movwf 12h ;postscale 1:1, prescala 4, timer 2 fijado (registro T2CON)
movlw 0Fh
movwf 17h ;inicializa CCP1CON (PWM)
clrf 05h ;secuencia para deshabilitar
movlw 07h ;operaciones de comparación en PORTA
movwf 1Fh ;y habilitar funciones I/O (registro CMCON)
run
movlw 02h
movwf 27h
;============================
;Secuencia para diferentes
;intensidades de color verde
;a una velocidad baja
;============================
one
movlw 0FFh
movwf 15h
call delay2
bcf 17h,04h
bcf 17h,05h
movlw 01h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 075h
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 75h
movwf 15h
call delay2
movlw 75h
movwf 15h
call delay2
movlw 75h
movwf 15h
call delay2
movlw 75h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
decfsz 27h,01h
goto one
movlw 05h
movwf 27h
;============================
;Secuencia para diferentes
;intensidades de color verde
;esta vez a una velocidad
;un poco más rápida
;============================
three
movlw 0FFh
movwf 15h
call delay3
bcf 17h,04h
bcf 17h,05h
movlw 01h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 075h
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
decfsz 27h,01h
goto three
movlw 02h
movwf 27h
;============================
;Secuencia para un difuminado
;del color verde
;============================
two
movlw 0FFh
movwf 25h
movwf 15h
down
decf 25h,01h
movf 25h,00h
movwf 15h
call delay
movf 15h,00h
xorlw 0FFh
bcf 17h,04h
bcf 17h,05h
btfss 03h,02h
goto down
up
incf 25h,01h
movf 25h,00h
movwf 15h
call delay
movf 15h,00h
xorlw 0FFh
bsf 17h,04h
bsf 17h,05h
btfss 03h,02h
goto up
decfsz 27h,01h
goto two
goto run
;============================
;GP DELAY
;============================
delay
movlw 07Fh
movwf 020h
w6
movlw 0ffh
movwf 021h
w7
decfsz 021h, 01h
goto w7
decfsz 020h, 01h
goto w6
return
delay2
movlw 09h
movwf 20h
w8
movlw 0ffh
movwf 21h
w9
movlw 0FFh
movwf 22h
w9.1
decfsz 22h, 01h
goto w9.1
decfsz 21h, 01h
goto w9
decfsz 20h, 01h
goto w8
return
delay3
movlw 0F1h
movwf 020h
w10
movlw 0ffh
movwf 021h
w11
decfsz 021h, 01h
goto w11
decfsz 020h, 01h
goto w10
return
end
;==========================
;Programa generador de PWM
;para controlar el color azul
;==========================
list p=16F628A
movlw 00h
movwf 0Bh
clrf 05h
clrf 06h
bsf 03h,05h
movlw 00h
movwf 86h
movlw 0FFh
movwf 92h ;inicializa CCP1 (registro PR2)
bcf 03h,05h
movlw 05h
movwf 12h ;postscale 1:1, prescala 4, timer 2 fijado (registro T2CON)
movlw 0Fh
movwf 17h ;inicializa CCP1CON (PWM)
clrf 05h ;secuencia para deshabilitar
movlw 07h ;operaciones de comparación en PORTA
movwf 1Fh ;y habilitar funciones I/O (registro CMCON)
run
movlw 02h
movwf 27h
;============================
;Secuencia para diferentes
;intensidades de color azul
;a una velocidad baja
;============================
one
movlw 01h
movwf 15h
call delay2
bcf 17h,04h
bcf 17h,05h
movlw 0FFh
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
movlw 01h
movlw 15h
call delay2
movlw 75h
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 0FFh
movwf 15h
call delay2
movlw 75h
movwf 15h
call delay2
movlw 01h
movwf 15h
call delay2
decfsz 27h,01h
goto one
movlw 05h
movwf 27h
;============================
;Secuencia para diferentes
;intensidades de color azul
;esta vez a una velocidad
;un poco más rápida
;============================
three
movlw 01h
movwf 15h
call delay3
bcf 17h,04h
bcf 17h,05h
movlw 0FFh
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 0FFh
movwf 15h
call delay3
movlw 75h
movwf 15h
call delay3
movlw 01h
movwf 15h
call delay3
decfsz 27h,01h
goto three
movlw 02h
movwf 27h
;============================
;Secuencia para un difuminado
;del color azul
;============================
two
movlw 00h
movwf 25h
movwf 15h
up
incf 25h,01h
movf 25h,00h
movwf 15h
call delay
movf 15h,00h
xorlw 0FFh
bsf 17h,04h
bsf 17h,05h
btfss 03h,02h
goto up
down
decf 25h,01h
movf 25h,00h
movwf 15h
call delay
movf 15h,00h
xorlw 0FFh
bcf 17h,04h
bcf 17h,05h
btfss 03h,02h
goto down
decfsz 27h,01h
goto two
goto run
;============================
;GP DELAY
;============================
delay
movlw 07Fh
movwf 020h
w6
movlw 0ffh
movwf 021h
w7
decfsz 021h, 01h
goto w7
decfsz 020h, 01h
goto w6
return
delay2
movlw 09h
movwf 020h
w8
movlw 0ffh
movwf 021h
w9
movlw 0FFh
movwf 22h
w9.1
decfsz 22h,01h
goto w9.1
decfsz 021h, 01h
goto w9
decfsz 020h, 01h
goto w8
return
delay3
movlw 0F1h
movwf 020h
w10
movlw 0ffh
movwf 021h
w11
decfsz 021h, 01h
goto w11
decfsz 020h, 01h
goto w10
return
end