LIST p=16F628 ;tell assembler what chip we are using
include "P16F628.inc" ;include the defaults for the chip
ERRORLEVEL 0, -302 ;suppress bank selection messages
__config 0x3D18 ;sets the configuration settings (oscillator type etc.)
;declarations
;======================================================================
cblock 0x20
W_temp
temp1
temp2
temp3
temp4
temp5
temp6
temp3t ;extra temp files
temp4t
temp5t
temp6t
total2t ;total temp files
total3t
time1
time2
total
total2
total3
count1
counta
countb
Mark5
count2
countc
countd
pwmt
pwmt2
pwm
pwm1
pwm2
pwm3
counte
countf
count3
count4
countg
counth
counti
countj
count6
d_temp
d_gap
_3times
endc
LEDP Equ PORTB
LEDT Equ TRISB
org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
goto Start
nop
nop
nop
org 0x0004 ;no isr acitivated
;goto isr
;sub-routine
;=======================================================================
;delays
;======================================================================
Start clrf PORTB ;make PortB outputs low (i.e. reset)
clrf PORTA
clrf count1
clrf count2
clrf count3
clrf count6
;goto $+2
;goto isr
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB all outputs
movwf LEDT
movlw b'00000000' ;set PortA all outputs
movwf TRISA
bcf STATUS, RP0
goto main
;========================
;PWM LENGTH ; RISES VERY QUICK
;==============================
on2 movfw W_temp
movwf PORTB
movfw temp4
movwf time1
call delay_3 ;was 3
decfsz time1, f ;100up
goto $-2
retlw 0x00
off2 movfw PORTB
movwf W_temp
clrf PORTB
movfw temp3
movwf time2
call delay_2 ;100up
decfsz time2, f ;
goto $-2
retlw 0x00
on3 movfw W_temp
movwf PORTB
movfw temp5
movwf time1
call delay_3 ;was 3
decfsz time1, f ;100up
goto $-2
retlw 0x00
off3 movfw PORTB
movwf W_temp
clrf PORTB
movfw temp6
movwf time2
call delay_2 ;100up
decfsz time2, f ;
goto $-2
retlw 0x00
retemp2 incf temp4, f
decf temp3, f
movfw pwmt2
movwf pwm2
retlw 0x00
retemp3 decf temp5, f
incf temp6, f
movfw pwmt2
movwf pwm2
retlw 0x00
retemp4 movfw temp4t ;retemp using copy temp t files orginally pending fast/slow
movwf temp4
movfw temp3t
movwf temp3
movfw total2t
movwf total2
movfw total3t
movwf total3
movfw temp5t
movwf temp5
movfw temp6t
movwf temp6
retlw 0x00
;==============================================================================
;for one off's
;==========================
LED movwf W_temp
on call on2
call off2
decfsz pwm2, f
goto $-3
call retemp2
decfsz total2, f
goto on
off call on3
call off3
decfsz pwm2, f
goto $-3
call retemp3
decfsz total3, f
goto off
retlw 0x00
;==============================================================================
;routine
;==========================
LED0 movlw b'00000001'
movwf W_temp
lpon0 call on2
call off2
decfsz pwm2, f
goto $-3
call retemp2
decfsz total2, f
goto lpon0
lpoff0 call on3
call off3
decfsz pwm2, f
goto $-3
call retemp3
decfsz total3, f
goto lpoff0
;loopd0 call delay_7
LED1 movlw b'00000010'
movwf W_temp
call retemp4
lpon1 call on2
call off2
decfsz pwm2, f
goto $-3
call retemp2
decfsz total2, f
goto lpon1
lpoff1 call on3
call off3
decfsz pwm2, f
goto $-3
call retemp3
decfsz total3, f
goto lpoff1
;loopd1 call delay_7
LED2 movlw b'00000100'
movwf W_temp
call retemp4
lpon2 call on2
call off2
decfsz pwm2, f
goto $-3
call retemp2
decfsz total2, f
goto lpon2
lpoff2 call on3
call off3
decfsz pwm2, f
goto $-3
call retemp3
decfsz total3, f
goto lpoff2
;loopd2 call delay_7
LED3 movlw b'00001000'
movwf W_temp
call retemp4
lpon3 call on2
call off2
decfsz pwm2, f
goto $-3
call retemp2
decfsz total2, f
goto lpon3
lpoff3 call on3
call off3
decfsz pwm2, f
goto $-3
call retemp3
decfsz total3, f
goto lpoff3
;loopd3 call delay_7
LED4 movlw b'00010000'
movwf W_temp
call retemp4
lpon4 call on2
call off2
decfsz pwm2, f
goto $-3
call retemp2
decfsz total2, f
goto lpon4
lpoff4 call on3
call off3
decfsz pwm2, f
goto $-3
call retemp3
decfsz total3, f
goto lpoff4
;loopd4 call delay_7
LED5 movlw b'00100000'
movwf W_temp
call retemp4
lpon5 call on2
call off2
decfsz pwm2, f
goto $-3
call retemp2
decfsz total2, f
goto lpon5
lpoff5 call on3
call off3
decfsz pwm2, f
goto $-3
call retemp3
decfsz total3, f
goto lpoff5
;loopd5 call delay_7
LED6 movlw b'01000000'
movwf W_temp
call retemp4
lpon6 call on2
call off2
decfsz pwm2, f
goto $-3
call retemp2
decfsz total2, f
goto lpon6
lpoff6 call on3
call off3
decfsz pwm2, f
goto $-3
call retemp3
decfsz total3, f
goto lpoff6
;loopd6 call delay_7
LED7 movlw b'10000000'
movwf W_temp
call retemp4
lpon7 call on2
call off2
decfsz pwm2, f
goto $-3
call retemp2
decfsz total2, f
goto lpon7
lpoff7 call on3
call off3
decfsz pwm2, f
goto $-3
call retemp3
decfsz total3, f
goto lpoff7
;loopd7 call delay_7
; call delay_7
; call delay_7
retlw 0x00
;==============================================================================================================
;normal fade rate setup - 6.5 seconds cycle
;==============================================================================================================
setup movlw d'1' ;datum 2
movwf pwmt
movfw pwmt
movwf pwm
movlw d'1' ;datum 1
movwf pwmt2
movfw pwmt2
movwf pwm2
movlw d'2'
movwf _3times
movlw d'10' ;9 x 200ms = 1.8 secs
movwf d_temp
retlw 0x00
slow movlw d'1'
movwf temp1
movlw d'240'
movwf temp2
movlw d'1' ;brightness start of second 12 is best
movwf temp4
movlw d'240'
movwf temp3
movlw d'175'
movwf total2
movlw d'176'
movwf temp5
movlw d'65'
movwf temp6
movlw d'175'
movwf total3
movlw d'1' ;brightness start of second 12 is best
movwf temp4t
movlw d'240'
movwf temp3t
movlw d'175'
movwf total2t
movlw d'176'
movwf temp5t
movlw d'65'
movwf temp6t
movlw d'175'
movwf total3t
retlw 0x00
fast movlw d'1'
movwf temp1
movlw d'240'
movwf temp2
movlw d'1' ;brightness start of second 12 is best
movwf temp4
movlw d'240'
movwf temp3
movlw d'120'
movwf total2
movlw d'121'
movwf temp5
movlw d'120'
movwf temp6
movlw d'120'
movwf total3
movlw d'1' ;brightness start of second 12 is best
movwf temp4t
movlw d'240'
movwf temp3t
movlw d'120'
movwf total2t
movlw d'121'
movwf temp5t
movlw d'120'
movwf temp6t
movlw d'120'
movwf total3t
retlw 0x00
;=========================================================================================
; MAIN PROGRAM
;=========================================================================================
main nop
nop
call setup
call fast
bsf PORTA, 0x00 ;fade 4 from top
call LED0
call delay_8
bcf PORTA, 0x00
;fast sparkle 1 led on 1
;bsf PORTA, 0x02 ;select ground
;call setup ;fill all temps
;call fast ;select slow fade level temps
;movlw b'00000010' ;select LED for illumination
;call LED ;fade on/off routine
;call delay_8 ;delay in pattern
;bcf PORTA, 0x02 ;turn off ground
;slow sparkle on 5
;call setup ;PIC 33333333333333
;call fast
;movlw b'01000000'
;call LED
;call delay_8
;fade 3 from half
;bsf PORTA, 0x01
;call setup
;call fast
;call LED4
;call delay_8
;bcf PORTA, 0x01
;delay balancing before goto main command
goto main
;=========================================================================================
delay_1 movlw d'20' ;25ms
movwf count1
d1 movlw d'199' ;= 199 - change to 20, for uP seconds.
movwf counta
movlw 0x01 ;= 1
movwf countb
Delay0 decfsz counta, f
goto $+2
decfsz countb, f
goto Delay0
decfsz count1 ,f
goto d1
retlw 0x00
delay_2 movlw d'1' ;100uP
movwf count2
d2 movlw d'21' ;was 19
movwf countc
movlw 0x01
movwf countd
Delay02 decfsz countc, f
goto $+2
decfsz countd, f
goto Delay02
decfsz count2, f
goto d2
retlw 0x00
delay_3 movlw d'1' ;was 1up, now 60
movwf count3
d3 movlw d'2' ;
movwf counte
movlw 0x01 ;
movwf countf
Delay03 decfsz counte, f
goto $+2
decfsz countf, f
goto Delay03
decfsz count3, f
goto d3
retlw 0x00
delay_6 movlw d'182' ;200ms
movwf count6
d6 movlw d'199' ;
movwf counti
movlw 0x01 ;
movwf countj
Delay06 decfsz counti, f
goto $+2
decfsz countj, f
goto Delay06
decfsz count6, f
goto d6
retlw 0x00
delay_7 movfw d_temp ;gap between PICs LED's 9secs
movwf d_gap
call delay_6
decfsz d_gap, f
goto $-2
retlw 0x00
delay_8 call delay_7
decfsz _3times, f
goto $-2
movlw d'2'
movwf _3times
retlw 0x00
;=======
;restore pwm latch
;===========
end