目次PIC回路集サインボード 2ソフトウェアメイン処理


サインボード 2 メイン処理
プログラムソースリスト

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
;********************************************************
;
;           The signboard control 2 processing
;
;                                 Author : Seiichi Inoue
;********************************************************

        list            p=pic16f84a
        include         p16f84a.inc
        __config _hs_osc & _wdt_off & _pwrte_on & _cp_off

;**************  Debugging mode setting  ****************
;For debugging mode, ";" of next line should be removed.
;#define  _debug

;****************  Label Definition  ********************

scrnhd         equ     h'10'    ;Screen area head address
scrnwhd        equ     h'20'    ;Screen work head address

h_timer        equ     h'30'    ;For Interruption
w_save         equ     h'31'
s_save         equ     h'32'

cnt500u        equ     h'33'    ;For Softwear Timer
cnt1m          equ     h'34'
cnt100m        equ     h'35'
cnt500m        equ     h'36'
cnt1s          equ     h'37'

cnt_t          equ     h'33'    ;For LED control
lpcnt          equ     h'34'
rowindex       equ     h'35'
porta_work     equ     h'36'
edge           equ     h'37'

;****************  Program Start  ***********************
        org     0               ;Reset Vector
        goto    init
        org     4               ;Interrupt Vector
        goto    int

;****************  Initial Process  *********************
        org     5
init    bsf     status,rp0      ;Change to Bank1
        clrf    trisa           ;Set PORTA to Output mode
        clrf    trisb           ;Set PORTB to Output mode
        bcf     status,rp0      ;Change to Bank0
        movf    portb,w         ;Read portb
        iorlw   h'80'           ;Set right data
        movwf   portb           ;Output data
        movlw   d'16'           ;Set loop count
        movwf   lpcnt           ;Save loop count
        movlw   d'15'           ;Set row index
        movwf   rowindex        ;Save row index
init_loop
        movlw   scrnhd          ;Set table head address
        addwf   rowindex,w      ;Head + Index
        movwf   fsr             ;Set table address
        movlw   h'7f'           ;Set OFF data
        movwf   indf            ;Write data
        decf    rowindex,f      ;Index - 1
        decfsz  lpcnt,f         ;Loop end ?
        goto    init_loop       ;No. Next row
        call    led_cnt         ;LED control

;******************  Main Process  **********************
main

; ここにサブルーチンを呼び出すコール文を入れる。

        goto    main

;********************************************************
;*    Required effect processings are put below.        *
;********************************************************


; ここにサブルーチンを入れる。


;***************  Interruption processing  **************
int
        retfie                  ;Not use

;********************************************************
;*    Required effect processings are put above.        *
;********************************************************

;*************  LED control Subroutine  *****************
led_cnt
        movlw   d'16'           ;Set loop count
        movwf   lpcnt           ;Save loop conut
        movlw   h'0f'           ;Set row index
        movwf   rowindex        ;Save index
loop
        rlf     rowindex,w      ;Set selector data
        iorlw   h'01'           ;CLK bit = 1
        movwf   porta_work      ;Save porta data
        movwf   porta           ;Output row data + CLK=1
        movf    portb,w         ;Read portb data
        andlw   h'80'           ;Pick-up edge data
        movwf   edge            ;Save edge data
        movlw   scrnhd          ;Set table head address
        addwf   rowindex,w      ;Head + Index
        movwf   fsr             ;Set Table address
        movf    indf,w          ;Read Data
        andlw   h'7f'           ;Pick-up LED control data
        iorwf   edge,w          ;Edge data + LED data
        movwf   portb           ;Output data
        call    w_timing        ;Wait
        movf    porta_work,w    ;Read porta data
        andlw   h'fe'           ;Set CLK=0
        movwf   porta           ;Output data latch pulse
        call    w_timing        ;Wait
        decf    rowindex,f      ;Index - 1
        decfsz  lpcnt,f         ;Loop end ?
        goto    loop            ;No. Next row
        return                  ;Yes. Count end


;       <<< Timer  Subroutine for 10MHz clock  >>>

;************  LED control timing Subroutine  ***********
;                    < About 100 us >
w_timing
       movlw   d'50'            ;Set loop count
#ifndef _debug
       movwf   cnt_t            ;Save loop count
w_loop
       nop                      ;Time adjust
       nop                      ;Time adjust
       decfsz  cnt_t,f          ;cnt_t-1=0 ?
       goto    w_loop           ;No. Continue
#endif
       return                   ;Count end

;*************  1msec Timer Subroutine  *****************
t1m     movlw   2               ;(1)       Set loop cnt1
#ifndef _debug
        movwf   cnt1m           ;(1)       Save loop cnt1
tm1lp1  movlw   d'249'          ;(1)*2     Set loop cnt2
        movwf   cnt500u         ;(1)*2     Save loop cnt2
tm1lp2  nop                     ;(1)*249*2 Time adjust
        nop                     ;(1)*249*2 Time adjust
        decfsz  cnt500u,f       ;(1)*249*2 cnt500u-1=0 ?
        goto    tm1lp2          ;(2)*248*2 No, continue
        decfsz  cnt1m,f         ;(1)*2     cnt1m-1=0 ?
        goto    tm1lp1          ;(2)       No. Continue
#endif
        return                  ;(2)       Yes. Cnt end
                                ;Total 2501*0.4usec=1msec

;*************  100msec Timer Subroutine  ***************
t100m   movlw   d'100'          ;Set loop counter
#ifndef _debug
        movwf   cnt100m         ;Save loop counter
tm2lp   call    t1m             ;1msec subroutine
        decfsz  cnt100m,f       ;cnt100m - 1 = 0 ?
        goto    tm2lp           ;No. Continue
#endif
        return                  ;Yes. Count end


;*************  500msec Timer Subroutine  ***************
t500m   movlw   5               ;Set loop counter
#ifndef _debug
        movwf   cnt500m         ;Save loop counter
tm3lp   call    t100m           ;100msec subroutine
        decfsz  cnt500m,f       ;cnt500m - 1 = 0 ?
        goto    tm3lp           ;No. Continue
#endif
        return                  ;Yes. Count end

;**************  1sec Timer Subroutine  *****************
t1s     movlw   2               ;Set loop counter
#ifndef _debug
        movwf   cnt1s           ;Save loop counter
tm4lp   call    t500m           ;500msec subroutine
        decfsz  cnt1s,f         ;cnt1s - 1 = 0 ?
        goto    tm4lp           ;No. Continue
#endif
        return                  ;Yes. Count end

;********************************************************
;          END of signboard 2 control processing
;********************************************************

        end

sign2_source.zip