;**********************************************************************
; Filename: girusu.asm *
; Date: 2002/3/20 *
; File Version: *
;**********************************************************************
list p=16F84 ; list directive to define processor
#include <p16F84.inc> ; processor specific variable definitions
LIST
; P16F84.INC Standard Header File, Version 2.00 Microchip Technology, Inc.
LIST
__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 EYE1 LED
;led_data,1 EYE2 LED
;led_data,2 BREAST1 LED
;led_data,3 BREAST2 LED
;led_data,4 BELT
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
wait_data2 EQU 0x18 ;wait data2 ram
eye1_count EQU 0x19 ;EYE1 LED count ram
eye2_count EQU 0x1a ;EYE2 LED count ram
bres1_count EQU 0x1b ;BREAST1 LED count ram
bres2_count EQU 0x1c ;BREAST2 LED count ram
belt_count EQU 0x1d ;BELT LED count ram
shift_data EQU 0x1e ;COLOR change
eye1_on EQU 0x20 ;EYE1 LED ON data ram
eye1_off EQU 0x21 ;EYE1 LED OFF data ram
eye2_on EQU 0x22 ;EYE2 LED ON data ram
eye2_off EQU 0x23 ;EYE2 LED OFF data ram
bres1_on EQU 0x24 ;BREAST1 LED ON data ram
bres1_off EQU 0x25 ;BREAST1 LED OFF data ram
bres2_on EQU 0x26 ;BREAST2 LED ON data ram
bres2_off EQU 0x27 ;BREAST2 LED OFF data ram
belt_on EQU 0x28 ;BELT LED ON data ram
belt_off EQU 0x29 ;BELT LED OFF data ram
int_count1 EQU 0x2d ;int count1
int_count2 EQU 0x2e ;int count2
int_count3 EQU 0x2f ;int count3
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
addwf int_count1,1
btfss STATUS,0
goto int_next2
movlw 01h
addwf int_count2,1
btfsc STATUS,0
incf int_count3,1
;---------------------------------
int_next2
movlw 01h ;LED mode auto shori
addwf acount1,1
btfsc STATUS,0
incf acount2,1
btfss acount2,0 ;
goto eye1_leds
call led_change
call led_set
call auto_clear
;----------------------- EYE1
eye1_leds decfsz eye1_count,1
goto eye2_leds
btfsc led_data,0 ;EYE1 OFF?
goto eye1_leds_2
eye1_leds_3 bsf led_data,0 ;EYE1 ON
movf eye1_on,0
movwf eye1_count
movf eye1_count,0
btfsc STATUS,2
goto eye1_leds_2
goto eye2_leds
eye1_leds_2 bcf led_data,0 ;EYE1 OFF
movf eye1_off,0
movwf eye1_count
movf eye1_count,0
btfsc STATUS,2
goto eye1_leds_3
;----------------------- EYE2
eye2_leds decfsz eye2_count,1
goto bres1_leds
btfsc led_data,1 ;EYE2 OFF?
goto eye2_leds_2
eye2_leds_3 bsf led_data,1 ;EYE2 ON
movf eye2_on,0
movwf eye2_count
movf eye2_count,0
btfsc STATUS,2
goto eye2_leds_2
goto bres1_leds
eye2_leds_2 bcf led_data,1 ;EYE2 OFF
movf eye2_off,0
movwf eye2_count
movf eye2_count,0
btfsc STATUS,2
goto eye2_leds_3
;----------------------- BREAST1
bres1_leds decfsz bres1_count,1
goto bres2_leds
btfsc led_data,2 ;BRES1 OFF?
goto bres1_leds_2
bres1_leds_3 bsf led_data,2 ;BRES1 ON
movf bres1_on,0
movwf bres1_count
movf bres1_count,0
btfsc STATUS,2
goto bres1_leds_2
goto bres2_leds
bres1_leds_2 bcf led_data,2 ;BRES1 OFF
movf bres1_off,0
movwf bres1_count
movf bres1_count,0
btfsc STATUS,2
goto bres1_leds_3
;----------------------- BREAST2
bres2_leds decfsz bres2_count,1
goto belt_leds
btfsc led_data,3 ;BRES2 OFF?
goto bres2_leds_2
bres2_leds_3 bsf led_data,3 ;BRES2 ON
movf bres2_on,0
movwf bres2_count
movf bres2_count,0
btfsc STATUS,2
goto bres2_leds_2
goto belt_leds
bres2_leds_2 bcf led_data,3 ;BRES2 OFF
movf bres2_off,0
movwf bres2_count
movf bres2_count,0
btfsc STATUS,2
goto bres2_leds_3
;------------------------ BELT
belt_leds decfsz belt_count,1
goto next_leds_3
btfsc led_data,4 ;BELT OFF?
goto belt_leds_2
belt_leds_3 bsf led_data,4 ;BELT ON
movf belt_on,0
movwf belt_count
movf belt_count,0
btfsc STATUS,2
goto belt_leds_2
goto next_leds_3
belt_leds_2 bcf led_data,4 ;BELT OFF
movf belt_off,0
movwf belt_count
movf belt_count,0
btfsc STATUS,2
goto belt_leds_3
;----------------------------------
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 00h
movwf PORTA
movlw 0e0h
movwf PORTB
call timer0_set
movlw 40h
movwf color_count
call auto_clear
movlw 01h
movwf shift_data
movlw 00h
movwf led_data ;LED ALL OFF
call set_lo_leds
movf eye1_on,0
movwf eye1_count ;EYE1 count data set
movf eye2_on,0
movwf eye2_count ;EYE2 count data set
movf bres1_on,0
movwf bres1_count ;BRES1 count data set
movf bres2_on,0
movwf bres2_count ;BRES2 count data set
movf belt_on,0
movwf belt_count ;BELT 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
call icnt_clear
movlw 0e0h
movwf PORTB
nop
sleep
nop
bcf INTCON,RBIE
nop
bsf INTCON,GIE
nop
bsf INTCON,T0IE
nop
call out1_out
;--------------------------------------
main_loop
btfsc int_count3,1
goto main_sleep2
;--------------------------------------
main_key
btfsc PORTB,5
goto eye1_led
call wait_1
call wait_1
btfsc PORTB,5
goto eye1_led
call shift_change
main_keyp
btfss PORTB,5
goto main_keyp
;--------------------------------------
eye1_led
btfss led_data,0
goto eye1_led_off
bsf PORTB,0
nop
goto eye2_led
eye1_led_off
bcf PORTB,0
nop
eye2_led
btfss led_data,1
goto eye2_led_off
bsf PORTB,1
nop
goto bres1_led
eye2_led_off
bcf PORTB,1
nop
;---------------------------------------
bres1_led
btfss led_data,2
goto bres1_led_off
bsf PORTB,2
nop
goto bres2_led
bres1_led_off
bcf PORTB,2
nop
bres2_led
btfss led_data,3
goto bres2_led_off
bsf PORTB,3
nop
goto belt_led
bres2_led_off
bcf PORTB,3
nop
;--------------------------------------
belt_led
btfss led_data,4
goto belt_led_off
bsf PORTB,4
nop
goto main_next_3
belt_led_off
bcf PORTB,4
nop
;--------------------------------------
main_next_3
goto main_loop
;--------------------------------------
main_sleep2
call out2_out
goto main_sleep
;-------------------------------------------------------------------------------
out1_out
bsf PORTA,0
nop
call wait_1
call wait_1
call wait_1
bcf PORTA,0
nop
return
out2_out
bsf PORTA,1
nop
call wait_1
call wait_1
call wait_1
bcf PORTA,1
nop
return
;-------------------------------------------------------------------------------
wait_1
movlw 0ffh
movwf wait_data
wait_2
nop
decfsz wait_data,1
goto wait_2
return
;-------------------------------------------------------------------------------
shift_change
btfss shift_data,3
goto shift_change2
movlw 01h
movwf shift_data
return
shift_change2
bcf STATUS,0
rlf shift_data,1
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 40h
movwf color_count
return
;-------------------------------------------------------------------------------
led_set
btfsc shift_data,0
goto led_set1
btfsc shift_data,1
goto led_set2
btfsc shift_data,2
goto led_set3
goto led_set4
;--------------------------------------
led_set1
call set_on_eye1
movwf eye1_on
sublw 70h
movwf eye1_off
call set_on_eye2
movwf eye2_on
sublw 70h
movwf eye2_off
call set_on_bres1
movwf bres1_on
sublw 70h
movwf bres1_off
call set_on_bres2
movwf bres2_on
sublw 70h
movwf bres2_off
call set_on_belt
movwf belt_on
sublw 70h
movwf belt_off
return
;--------------------------------------
led_set2
call set_on_bres1
movwf eye1_on
sublw 70h
movwf eye1_off
call set_on_bres2
movwf eye2_on
sublw 70h
movwf eye2_off
call set_on_eye1
movwf bres1_on
sublw 70h
movwf bres1_off
call set_on_eye2
movwf bres2_on
sublw 70h
movwf bres2_off
call set_on_belt
movwf belt_on
sublw 70h
movwf belt_off
return
;--------------------------------------
led_set3
call set_on_eye1
movwf eye1_on
sublw 70h
movwf eye1_off
call set_on_eye2
movwf eye2_on
sublw 70h
movwf eye2_off
call set_on_belt
movwf bres1_on
sublw 70h
movwf bres1_off
call set_on_belt
movwf bres2_on
sublw 70h
movwf bres2_off
call set_on_bres1
movwf belt_on
sublw 70h
movwf belt_off
return
;--------------------------------------
led_set4
call set_on_bres1
movwf eye1_on
sublw 70h
movwf eye1_off
call set_on_bres2
movwf eye2_on
sublw 70h
movwf eye2_off
call set_on_belt
movwf bres1_on
sublw 70h
movwf bres1_off
call set_on_belt
movwf bres2_on
sublw 70h
movwf bres2_off
call set_on_eye1
movwf belt_on
sublw 70h
movwf belt_off
return
;--------------------------------------------------------------------------------
icnt_clear movlw 00h
movwf int_count1
movwf int_count2
movwf int_count3
return
;--------------------------------------------------------------------------------
set_on_eye1 movf color_count,0
movwf taihi
movlw low(eye1_on_table)
addwf taihi,1
movlw high(eye1_on_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
eye1_on_table
retlw 00h
retlw 00h
retlw 00h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 00h
retlw 01h
retlw 02h
retlw 03h
retlw 04h
retlw 05h
retlw 06h
retlw 07h
retlw 06h
retlw 05h
retlw 04h
retlw 03h
retlw 02h
retlw 01h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 02h
retlw 01h
retlw 02h
retlw 01h
retlw 02h
retlw 01h
retlw 02h
retlw 01h
retlw 02h
retlw 01h
retlw 00h
;--------------------------------------------------------------------------------
set_on_eye2 movf color_count,0
movwf taihi
movlw low(eye2_on_table)
addwf taihi,1
movlw high(eye2_on_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
eye2_on_table
retlw 00h
retlw 00h
retlw 00h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 00h
retlw 01h
retlw 02h
retlw 03h
retlw 04h
retlw 05h
retlw 06h
retlw 07h
retlw 06h
retlw 05h
retlw 04h
retlw 03h
retlw 02h
retlw 01h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 02h
retlw 01h
retlw 02h
retlw 01h
retlw 02h
retlw 01h
retlw 02h
retlw 01h
retlw 02h
retlw 01h
retlw 00h
;--------------------------------------------------------------------------------
set_on_bres1 movf color_count,0
movwf taihi
movlw low(bres1_on_table)
addwf taihi,1
movlw high(bres1_on_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
bres1_on_table
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 01h
retlw 02h
retlw 03h
retlw 02h
retlw 01h
retlw 02h
retlw 03h
retlw 02h
retlw 01h
retlw 02h
retlw 03h
retlw 02h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 06h
retlw 04h
retlw 02h
retlw 01h
retlw 02h
retlw 04h
retlw 06h
retlw 07h
retlw 06h
retlw 04h
retlw 02h
retlw 01h
retlw 01h
retlw 01h
retlw 01h
retlw 01h
retlw 02h
retlw 03h
retlw 04h
retlw 05h
retlw 06h
retlw 07h
retlw 06h
retlw 05h
retlw 04h
retlw 03h
retlw 02h
retlw 01h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
;--------------------------------------------------------------------------------
set_on_bres2 movf color_count,0
movwf taihi
movlw low(bres2_on_table)
addwf taihi,1
movlw high(bres2_on_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
bres2_on_table
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 01h
retlw 02h
retlw 03h
retlw 02h
retlw 01h
retlw 02h
retlw 03h
retlw 02h
retlw 01h
retlw 02h
retlw 03h
retlw 02h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 07h
retlw 07h
retlw 07h
retlw 07h
retlw 06h
retlw 04h
retlw 02h
retlw 01h
retlw 02h
retlw 04h
retlw 06h
retlw 07h
retlw 06h
retlw 04h
retlw 02h
retlw 01h
retlw 02h
retlw 03h
retlw 04h
retlw 05h
retlw 06h
retlw 07h
retlw 06h
retlw 05h
retlw 04h
retlw 03h
retlw 02h
retlw 01h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
;--------------------------------------------------------------------------------
set_on_belt movf color_count,0
movwf taihi
movlw low(belt_on_table)
addwf taihi,1
movlw high(belt_on_table)
movwf PCLATH
addcf PCLATH,1
movf taihi,0
movwf PCL
belt_on_table
retlw 00h
retlw 07h
retlw 07h
retlw 07h
retlw 07h
retlw 06h
retlw 05h
retlw 04h
retlw 03h
retlw 02h
retlw 01h
retlw 00h
retlw 01h
retlw 02h
retlw 03h
retlw 04h
retlw 05h
retlw 06h
retlw 07h
retlw 05h
retlw 03h
retlw 01h
retlw 01h
retlw 01h
retlw 02h
retlw 02h
retlw 02h
retlw 01h
retlw 01h
retlw 01h
retlw 02h
retlw 02h
retlw 01h
retlw 01h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 00h
retlw 01h
retlw 02h
retlw 03h
retlw 04h
retlw 05h
retlw 06h
retlw 07h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
retlw 01h
retlw 03h
retlw 05h
retlw 07h
;-------------------------------------------------------------------------------
set_lo_leds movlw 00h
movwf eye1_on
movwf eye2_on
movwf bres1_on
movwf bres2_on
movwf belt_on
movlw 70h
movwf eye1_off
movwf eye2_off
movwf bres1_off
movwf bres2_off
movwf belt_off
return
;-------------------------------------------------------------------------------
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 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'
|