;**********************************************************************
; Filename: valtan.asm *
; Date: 2001/11/23 *
; 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
led_data EQU 0x11 ;LED set data
;led_data,0 TENTOU LED
acount1 EQU 0x13 ;LED auto count ram1
acount2 EQU 0x14 ;LED auto count ram2
wait_data EQU 0x15 ;wait data ram
color_count EQU 0x16 ;color count ram
taihi EQU 0x17 ;taihi data
tentou_count EQU 0x19 ;TENTOU LED count ram
push_key EQU 0x1e ;push key
;push_key,0 REC_KEY
;push_key,1 PLAY_KEY
tentou_on EQU 0x20 ;RED LED ON data ram
tentou_off EQU 0x21 ;RED LED OFF data ram
tm0_setdata EQU 0f3h ;FFH-F3H=12 12*16=192usec
;**********************************************************************
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
;---------------------------------
movlw 01h ;LED mode auto shori
addwf acount1,1
btfsc STATUS,0
incf acount2,1
btfss acount2,0 ;
goto tentou_leds
call led_change
call led_set
call auto_clear
;----------------------- LED
tentou_leds decfsz tentou_count,1
goto next_leds
btfsc led_data,0 ;LED OFF?
goto tentou_leds_2
tentou_leds_3 bsf led_data,0 ;LED ON
movf tentou_on,0
movwf tentou_count
movf tentou_count,0
btfsc STATUS,2
goto tentou_leds_2
goto next_leds
tentou_leds_2 bcf led_data,0 ;LED OFF
movf tentou_off,0
movwf tentou_count
movf tentou_count,0
btfsc STATUS,2
goto tentou_leds_3
;----------------------------------
next_leds
;----------------------------------
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 0efh
movwf PORTB
call timer0_set
movlw 1Ch
movwf color_count
call auto_clear
movlw 00h
movwf led_data ;LED OFF
call set_lo_leds
movf tentou_on,0
movwf tentou_count ;LED count data set
main_sleep
bcf INTCON,GIE
nop
bcf INTCON,T0IE
nop
bcf INTCON,T0IF
nop
bcf INTCON,RBIF
nop
bsf INTCON,RBIE
nop
movlw 0efh
movwf PORTB
movlw 00h
movwf push_key
nop
sleep
nop
bcf INTCON,RBIE
nop
bsf INTCON,GIE
nop
bsf INTCON,T0IE
nop
;--------------------------------------- REMOTE INPUT
btfsc PORTB,7
goto main_key1
bsf push_key,1
goto main_key2r
;--------------------------------------- REC KEY
main_key1
btfsc PORTB,5
goto main_key2
call wait_1
btfsc PORTB,5
goto main_key2
bsf push_key,0
main_key1p btfss PORTB,5
goto main_key1p
bcf PORTA,1 ;PD L
nop
bcf PORTA,2 ;REC MODE
nop
bcf PORTA,0 ;CE L(REC START)
nop
bsf PORTA,0 ;CE H
goto main_loop
;--------------------------------------- PLAY KEY
main_key2
btfsc PORTB,6
goto main_key3
call wait_1
btfsc PORTB,6
goto main_key3
bsf push_key,1
main_key2p btfss PORTB,6
goto main_key2p
main_key2r bcf PORTA,1 ;PD L
nop
bsf PORTA,2 ;PLAY MODE
nop
bcf PORTA,0 ;CE L(PLAY START)
nop
bsf PORTA,0 ;CE H
goto main_loop
;---------------------------------------
main_key3
;--------------------------------------
main_loop
btfsc push_key,0
goto red_led
btfsc push_key,1
goto green_led
;--------------------------------------
goto main_sleep
;--------------------------------------
red_led
btfss led_data,0
goto red_led_off
bcf PORTB,1
nop
goto main_next
red_led_off
bsf PORTB,1
nop
goto main_next
;--------------------------------------
green_led
btfss led_data,0
goto green_led_off
bcf PORTB,0
nop
goto main_next
green_led_off
bsf PORTB,0
nop
goto main_next
;---------------------------------------
main_next
;--------------------------------------- REC KEY
main_key4
btfsc PORTB,5
goto main_key5
call wait_1
btfsc PORTB,5
goto main_key5
btfss push_key,0
goto main_key5
bcf push_key,0
main_key4p btfss PORTB,5
goto main_key4p
goto main_nexte1s
;--------------------------------------- PLAY KEY
main_key5
btfsc PORTB,6
goto main_key6
call wait_1
btfsc PORTB,6
goto main_key6
btfss push_key,1
goto main_key6
bcf push_key,1
main_key5p btfss PORTB,6
goto main_key5p
goto main_nexte2s
;---------------------------------------
main_key6
;---------------------------------------
main_nexte
btfsc PORTA,3 ;EOM=L
goto main_loop
;---------------------------------------
main_nexte1
btfss push_key,0
goto main_nexte2
main_nexte1s
bcf PORTA,0 ;CE L(REC STOP)
nop
bsf PORTA,0 ;CE H
nop
bsf PORTA,1 ;PD H
goto main_sleep
;--------------------------------------
main_nexte2
btfss push_key,1
goto main_nexte3
main_nexte2s
bcf PORTA,0 ;CE L(PLAY STOP)
nop
bsf PORTA,0 ;CE H
nop
bsf PORTA,1 ;PD H
goto main_sleep
;--------------------------------------
main_nexte3
goto main_sleep
;-------------------------------------------------------------------------------
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
;-------------------------------------------------------------------------------
led_change decf color_count,1
btfsc STATUS,2
goto led_change2
return
led_change2 movlw 1Ch
movwf color_count
return
;-------------------------------------------------------------------------------
led_set call set_on_led
movwf tentou_on
sublw 70h
movwf tentou_off
return
;--------------------------------------------------------------------------------
set_on_led movf color_count,0
movwf taihi
movlw low(led_on_table)
addwf taihi,1
movlw high(led_on_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
led_on_table retlw 70h
retlw 00h
retlw 10h
retlw 20h
retlw 30h
retlw 40h
retlw 50h
retlw 60h
retlw 70h
retlw 60h
retlw 50h
retlw 40h
retlw 30h
retlw 20h
retlw 10h
retlw 00h
retlw 10h
retlw 20h
retlw 30h
retlw 40h
retlw 50h
retlw 60h
retlw 70h
retlw 60h
retlw 50h
retlw 40h
retlw 30h
retlw 20h
retlw 10h
;-------------------------------------------------------------------------------
set_lo_leds movlw 00h
movwf tentou_on
movlw 70h
movwf tentou_off
return
;-------------------------------------------------------------------------------
port_set ;RA0,RA1,RA2,RA4(OUT)
;RA3(IN)
;RB0,RB1,RB2,RB3,RB4(OUT)
;RB5,RB6,RB7(IN)
bsf STATUS,RP0
clrf TRISA
bsf TRISA,3
nop
clrf TRISB
bsf TRISB,7
nop
bsf TRISB,6
nop
bsf TRISB,5
nop
bcf STATUS,RP0
return
timer0_set
bsf STATUS,RP0
movlw 083h ;(1)PORTB NOT PULLUP
;(0)INTEDG
;(0)TOCS
;(0)TOSE
;(0)PSA
;(011)1/16
movwf OPTION_REG
bcf STATUS,RP0
movlw tm0_setdata
movwf TMR0
return
END ; directive 'end of program'
|