;**********************************************************************
; Filename: v3mat.asm *
; Date: 2001/10/7 *
; File Version: *
;**********************************************************************
list p=16F84 ; list directive to define processor
#include <p16F84.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;***** VARIABLE DEFINITIONS
w_temp EQU 0x0C ; variable used for context saving
status_temp EQU 0x0D ; variable used for context saving
run_mode EQU 0x10 ;run mode
;run_mode,0 run flg(0=run,1=stop)
acount1 EQU 0x13 ;LED auto count ram1
acount2 EQU 0x14 ;LED auto count ram2
wait_data EQU 0x15 ;wait data ram
moji_count EQU 0x16 ;moji count ram
taihi EQU 0x17 ;taihi data
out_data EQU 0x18 ;out data
disp_mode EQU 0x19 ;display mode
zurasu EQU 0x1a ;zurasu retu
retu_count EQU 0x20 ;retu count data
int_count1 EQU 0x2d ;int count1
int_count2 EQU 0x2e ;int count2
tm0_setdata EQU 063h ;255-156=99=63H 156*128=19.968msec
;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
;---------------------------------------------------------------
bcf INTCON,T0IF
movlw tm0_setdata
movwf TMR0
;---------------------------------
btfsc run_mode,0
goto int_end
;---------------------------------
movlw 01h
addwf int_count1,1
btfss STATUS,0
goto int_next2
movlw 01h
addwf int_count2,1
;---------------------------------
int_next2
movlw 01h ;LED mode auto shori
addwf acount1,1
btfsc STATUS,0
incf acount2,1
btfss acount1,2 ;
goto next_leds_3
;------------------------
incf zurasu,1
call auto_clear
movf zurasu,0
sublw 10h
btfss STATUS,2
goto next_leds_3
call zura_clear
;------------------------
incf moji_count,1
movf moji_count,0
sublw 8h ;moji count max
btfss STATUS,2
goto next_leds_3
call moji_clear
;-----------------------
next_leds_3
;----------------------------------
int_end
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
;--------------------------------------------------------------------------
main
call port_set
movlw 0ffh
movwf PORTA
movlw 0c0h
movwf PORTB
call timer0_set
call retu_shoki
call auto_clear
call moji_clear
call mode_clear
call zura_clear
movlw 00h
movwf run_mode
main_sleep
bcf INTCON,GIE
nop
bcf INTCON,T0IE
nop
bcf INTCON,T0IF
nop
bcf INTCON,RBIF
nop
bsf INTCON,RBIE
nop
call icnt_clear
movlw 0c0h
movwf PORTB
nop
sleep
nop
bcf INTCON,RBIE
nop
bsf INTCON,GIE
nop
bsf INTCON,T0IE
nop
call moji_clear
main_key0 btfss PORTB,6
goto main_key0
;--------------------------------------
main_loop
btfsc int_count2,2
goto main_sleep
;--------------------------------------- SW2 KEY
main_key1
btfsc PORTB,5
goto main_key2
call wait_1
call wait_1
btfsc PORTB,5
goto main_key2
call disp_change
main_key1p btfss PORTB,5
goto main_key1p
;-------------------------------------- SW1 key
main_key2
btfsc PORTB,6
goto main_led
call wait_1
call wait_1
btfsc PORTB,6
goto main_led
call run_change
main_key2p btfss PORTB,6
goto main_key2p
;---------------------------------------
main_led
decf retu_count,0
iorlw 10h
movwf PORTA
bsf PORTB,2
nop
bsf PORTB,3
nop
;--------------------------------------
btfsc disp_mode,0
goto pattern1
btfsc disp_mode,1
goto pattern2
btfsc disp_mode,2
goto pattern3
btfsc disp_mode,3
goto pattern4
btfsc disp_mode,4
goto pattern5
btfsc disp_mode,5
goto pattern6
btfsc disp_mode,6
goto pattern7
btfsc disp_mode,7
goto pattern8
goto pattern8
;-------------------------------------- green and red
pattern1
call green_data_10
call data_out
call green_data_20
call data_out
bcf PORTB,2
nop
call red_data_10
call data_out
call red_data_20
call data_out
goto main_next
;-------------------------------------- red and red (orange)
pattern2
call red_data_10
call data_out
call red_data_20
call data_out
bcf PORTB,2
nop
call red_data_10
call data_out
call red_data_20
call data_out
goto main_next
;--------------------------------------- green only
pattern3
call green_data_10
call data_out
call green_data_20
call data_out
bcf PORTB,2
nop
movlw 0ffh
call data_out
movlw 0ffh
call data_out
goto main_next
;--------------------------------------- red only
pattern4
movlw 0ffh
call data_out
movlw 0ffh
call data_out
bcf PORTB,2
nop
call red_data_10
call data_out
call red_data_20
call data_out
goto main_next
;--------------------------------------- green only
pattern5
movlw 0ffh
call data_out
movlw 0ffh
call data_out
bcf PORTB,2
nop
call green_data_10
call data_out
call green_data_20
call data_out
goto main_next
;--------------------------------------- red only
pattern6
call red_data_10
call data_out
call red_data_20
call data_out
bcf PORTB,2
nop
movlw 0ffh
call data_out
movlw 0ffh
call data_out
goto main_next
;--------------------------------------- green red change
pattern7
call red_data_10
call data_out
call red_data_20
call data_out
bcf PORTB,2
nop
call green_data_10
call data_out
call green_data_20
call data_out
goto main_next
;-------------------------------------- green and green (orange)
pattern8
call green_data_10
call data_out
call green_data_20
call data_out
bcf PORTB,2
nop
call green_data_10
call data_out
call green_data_20
call data_out
goto main_next
;---------------------------------------
main_next
bcf PORTB,3
nop
bcf PORTA,4
nop
call wait_1
bsf PORTA,4
nop
decf retu_count,1
btfsc STATUS,2
goto main_led_next
goto main_led
;---------------------------------------
main_led_next call retu_shoki
goto main_loop
;-------------------------------------------------------------------------------
wait_1
movlw 0ffh
movwf wait_data
wait_2
nop
decfsz wait_data,1
goto wait_2
return
;-------------------------------------------------------------------------------
auto_clear movlw 00h
movwf acount1 ;LED auto count clear
movwf acount2
return
;-------------------------------------------------------------------------------
retu_shoki
movlw 10h
movwf retu_count
return
;--------------------------------------------------------------------------------
icnt_clear movlw 00h
movwf int_count1
movwf int_count2
return
;--------------------------------------------------------------------------------
moji_clear movlw 00h
movwf moji_count
return
;--------------------------------------------------------------------------------
mode_clear movlw 01h
movwf disp_mode
return
;--------------------------------------------------------------------------------
zura_clear movlw 00h
movwf zurasu
return
;--------------------------------------------------------------------------------
disp_change btfss disp_mode,7
goto disp_change2
goto mode_clear
disp_change2 bcf STATUS,0
rlf disp_mode,1
return
;--------------------------------------------------------------------------------
run_change btfss run_mode,0
goto run_change2
bcf run_mode,0
return
run_change2 bsf run_mode,0
return
;--------------------------------------------------------------------------------
data_out
movwf out_data
bcf PORTB,1
btfsc out_data,7
bsf PORTB,1
call clk
bcf PORTB,1
btfsc out_data,6
bsf PORTB,1
call clk
bcf PORTB,1
btfsc out_data,5
bsf PORTB,1
call clk
bcf PORTB,1
btfsc out_data,4
bsf PORTB,1
call clk
bcf PORTB,1
btfsc out_data,3
bsf PORTB,1
call clk
bcf PORTB,1
btfsc out_data,2
bsf PORTB,1
call clk
bcf PORTB,1
btfsc out_data,1
bsf PORTB,1
call clk
bcf PORTB,1
btfsc out_data,0
bsf PORTB,1
call clk
return
;--------------------------------------------------------------------------------
clk
bsf PORTB,0
nop
bcf PORTB,0
nop
return
;--------------------------------------------------------------------------------
green_data_10 movf retu_count,0
movwf taihi
swapf moji_count,0
addwf taihi,1
movf zurasu,0
addwf taihi,1
movlw low(green10_table)
addwf taihi,1
movlw high(green10_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
green10_table retlw 00h
retlw 0FF
retlw 0FE
retlw 080
retlw 0BF
retlw 0BF
retlw 098
retlw 09F
retlw 0A7
retlw 0B3
retlw 09F
retlw 0CC
retlw 09F
retlw 0B3
retlw 0A0
retlw 08F
retlw 0FF
green11_table
retlw 0FF
retlw 080
retlw 0BF
retlw 0BF
retlw 0A0
retlw 0BF
retlw 0BF
retlw 0A5
retlw 0A5
retlw 0BF
retlw 0BF
retlw 0A0
retlw 0BF
retlw 0BF
retlw 080
retlw 0FF
green12_table
retlw 0FF
retlw 0FF
retlw 0FE
retlw 0FE
retlw 08E
retlw 0AE
retlw 0AE
retlw 0A6
retlw 0B6
retlw 090
retlw 0DC
retlw 0CF
retlw 0E3
retlw 0F8
retlw 0FF
retlw 0FF
green13_table
retlw 0FF
retlw 0FF
retlw 0F8
retlw 0FA
retlw 0FA
retlw 0FB
retlw 0F9
retlw 081
retlw 0BF
retlw 0BF
retlw 080
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
green14_table
retlw 0FF
retlw 0FF
retlw 08C
retlw 0AD
retlw 0AD
retlw 0A4
retlw 0B5
retlw 091
retlw 0DB
retlw 0CE
retlw 0EF
retlw 0EB
retlw 0E0
retlw 0FF
retlw 0FF
retlw 0FF
green15_table
retlw 0FF
retlw 0FF
retlw 0FE
retlw 0FC
retlw 0FD
retlw 0FD
retlw 0FD
retlw 0FD
retlw 0FD
retlw 0FD
retlw 0FD
retlw 0FD
retlw 0FD
retlw 0FC
retlw 0FF
retlw 0FF
green16_table
retlw 0FF
retlw 08E
retlw 0AE
retlw 0A0
retlw 0A7
retlw 0AF
retlw 0BD
retlw 0B5
retlw 0B5
retlw 0BD
retlw 0AF
retlw 0A7
retlw 0A0
retlw 0AE
retlw 08E
retlw 0FF
green17_table
retlw 0FF
retlw 0E3
retlw 0EB
retlw 0E8
retlw 0EF
retlw 0C7
retlw 0D4
retlw 09E
retlw 0AF
retlw 0B7
retlw 09E
retlw 0AE
retlw 0BE
retlw 09E
retlw 0C0
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
green_data_20 movf retu_count,0
movwf taihi
swapf moji_count,0
addwf taihi,1
movf zurasu,0
addwf taihi,1
movlw low(green20_table)
addwf taihi,1
movlw high(green20_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
green20_table retlw 00h
retlw 0FF
retlw 03F
retlw 08F
retlw 0E3
retlw 0FB
retlw 01B
retlw 0FB
retlw 0FB
retlw 0CB
retlw 0CB
retlw 04B
retlw 0CB
retlw 0CB
retlw 00B
retlw 0E3
retlw 0FF
green21_table
retlw 0FF
retlw 003
retlw 0CB
retlw 0CB
retlw 04B
retlw 0CB
retlw 0FB
retlw 07B
retlw 04B
retlw 0CB
retlw 0CB
retlw 04B
retlw 0CB
retlw 0CB
retlw 003
retlw 0FF
green22_table
retlw 0FF
retlw 0FF
retlw 03F
retlw 087
retlw 097
retlw 097
retlw 097
retlw 097
retlw 097
retlw 097
retlw 097
retlw 097
retlw 087
retlw 03F
retlw 0FF
retlw 0FF
green23_table
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 07F
retlw 07F
retlw 03F
retlw 09F
retlw 0CF
retlw 0E7
retlw 033
retlw 09B
retlw 0CB
retlw 0E3
retlw 0FF
retlw 0FF
green24_table
retlw 0FF
retlw 0FF
retlw 07F
retlw 03F
retlw 08F
retlw 0E3
retlw 07B
retlw 05B
retlw 043
retlw 043
retlw 0DB
retlw 0DB
retlw 01B
retlw 0DB
retlw 0C3
retlw 0FF
green25_table
retlw 0FF
retlw 0FF
retlw 03F
retlw 0BF
retlw 0BF
retlw 03F
retlw 07F
retlw 07F
retlw 07F
retlw 07F
retlw 07F
retlw 07F
retlw 07F
retlw 07F
retlw 0FF
retlw 0FF
green26_table
retlw 0FF
retlw 03F
retlw 083
retlw 0AB
retlw 0EB
retlw 06B
retlw 07B
retlw 05B
retlw 05B
retlw 073
retlw 077
retlw 0F7
retlw 0A7
retlw 08F
retlw 03F
retlw 0FF
green27_table
retlw 0FF
retlw 01F
retlw 05F
retlw 043
retlw 0FB
retlw 0FB
retlw 0C3
retlw 0FB
retlw 0FB
retlw 0AB
retlw 0AB
retlw 0FB
retlw 0FB
retlw 083
retlw 03F
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
red_data_10 movf retu_count,0
movwf taihi
swapf moji_count,0
addwf taihi,1
movf zurasu,0
addwf taihi,1
movlw low(red10_table)
addwf taihi,1
movlw high(red10_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
red10_table retlw 00h
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0C0
retlw 0C0
retlw 0E7
retlw 0E0
retlw 0D8
retlw 0CC
retlw 0E0
retlw 0F3
retlw 0E0
retlw 0CC
retlw 0DF
retlw 0FF
retlw 0FF
red11_table
retlw 0FF
retlw 0FF
retlw 0C0
retlw 0C0
retlw 0DF
retlw 0C0
retlw 0C0
retlw 0DA
retlw 0DA
retlw 0C0
retlw 0C0
retlw 0DF
retlw 0C0
retlw 0C0
retlw 0FF
retlw 0FF
red12_table
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0DF
retlw 0DF
retlw 0DF
retlw 0CF
retlw 0EF
retlw 0E3
retlw 0F0
retlw 0FC
retlw 0FF
retlw 0FF
retlw 0FF
red13_table
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FD
retlw 0FD
retlw 0FC
retlw 0FE
retlw 0FE
retlw 0C0
retlw 0C0
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
red14_table
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0DE
retlw 0DE
retlw 0DF
retlw 0CE
retlw 0EE
retlw 0E4
retlw 0F1
retlw 0F0
retlw 0F4
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
red15_table
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FE
retlw 0FE
retlw 0FE
retlw 0FE
retlw 0FE
retlw 0FE
retlw 0FE
retlw 0FE
retlw 0FE
retlw 0FF
retlw 0FF
retlw 0FF
red16_table
retlw 0FF
retlw 0FF
retlw 0DF
retlw 0DF
retlw 0D8
retlw 0D0
retlw 0C2
retlw 0CA
retlw 0CA
retlw 0C2
retlw 0D0
retlw 0D8
retlw 0DF
retlw 0DF
retlw 0FF
retlw 0FF
red17_table
retlw 0FF
retlw 0FF
retlw 0F7
retlw 0F7
retlw 0F0
retlw 0F8
retlw 0EB
retlw 0E1
retlw 0D0
retlw 0C8
retlw 0E1
retlw 0D1
retlw 0C1
retlw 0E1
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
red_data_20 movf retu_count,0
movwf taihi
swapf moji_count,0
addwf taihi,1
movf zurasu,0
addwf taihi,1
movlw low(red20_table)
addwf taihi,1
movlw high(red20_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
red20_table retlw 00h
retlw 0FF
retlw 0FF
retlw 07F
retlw 01F
retlw 007
retlw 0E7
retlw 007
retlw 007
retlw 037
retlw 037
retlw 0B7
retlw 037
retlw 037
retlw 0F7
retlw 0FF
retlw 0FF
red21_table
retlw 0FF
retlw 0FF
retlw 037
retlw 037
retlw 0B7
retlw 037
retlw 007
retlw 087
retlw 0B7
retlw 037
retlw 037
retlw 0B7
retlw 037
retlw 037
retlw 0FF
retlw 0FF
red22_table
retlw 0FF
retlw 0FF
retlw 0FF
retlw 07F
retlw 06F
retlw 06F
retlw 06F
retlw 06F
retlw 06F
retlw 06F
retlw 06F
retlw 06F
retlw 07F
retlw 0FF
retlw 0FF
retlw 0FF
red23_table
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 07F
retlw 03F
retlw 01F
retlw 0CF
retlw 0E7
retlw 0F7
retlw 0FF
retlw 0FF
retlw 0FF
red24_table
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 07F
retlw 01F
retlw 087
retlw 0A7
retlw 0BF
retlw 0BF
retlw 027
retlw 027
retlw 0E7
retlw 0E7
retlw 0FF
retlw 0FF
red25_table
retlw 0FF
retlw 0FF
retlw 0FF
retlw 07F
retlw 07F
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
red26_table
retlw 0FF
retlw 0FF
retlw 07F
retlw 057
retlw 017
retlw 097
retlw 087
retlw 0A7
retlw 0A7
retlw 08F
retlw 08F
retlw 00F
retlw 05F
retlw 07F
retlw 0FF
retlw 0FF
red27_table
retlw 0FF
retlw 0FF
retlw 0BF
retlw 0BF
retlw 007
retlw 007
retlw 03F
retlw 007
retlw 007
retlw 057
retlw 057
retlw 007
retlw 007
retlw 07F
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
retlw 0FF
;-------------------------------------------------------------------------------
;-------------------------------------------------------------------------------
port_set ;RA0,RA1,RA2,RA3,RA4(OUT)
;RB0,RB1,RB2,RB3,RB4(OUT)
;RB5,RB6,RB7(IN)
bsf STATUS,RP0
clrf TRISA
clrf TRISB
bsf TRISB,7
nop
bsf TRISB,6
nop
bsf TRISB,5
nop
bcf STATUS,RP0
return
timer0_set
bsf STATUS,RP0
movlw 086h ;(1)PORTB NOT PULLUP
;(0)INTEDG
;(0)TOCS
;(0)TOSE
;(0)PSA
;(110)1/128
movwf OPTION_REG
bcf STATUS,RP0
movlw tm0_setdata
movwf TMR0
return
END ; directive 'end of program'
|