[Menu]>[Circuits Gallery]>[Signboard 2]>[Software]

Software for Signboard 2
[Dissolve]

This routine sholud be put on the main process. Function This routine displays the data which was set to the workarea bit by bit at random. The position of the displayed data isn't shifted. Timer register (TMR0) is used to display randomly. So, when you use this subroutine, the Edge LED Timer should be used. When you don't use an Edge LED Timer, the random number doesn't occur and it has an LED display comparatively regularly. In the lighting-up interval, it is 100 milliseconds per bit. In the animation which is shown above, it is culling to make a file size small. Source code
    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
    ;**********************  Dissolve  **********************
            cblock         h'38'
            dis_lp
            dis_bit
            dis_row
            dis_datas
            dis_dataw
            dis_work1
            dis_work2
            endc

    scrnchd        equ     h'40'

    dissolve
            movlw   d'16'           ;Set loop count
            movwf   dis_lp          ;Save loop count
            movlw   scrnchd         ;Set screen check head
            movwf   dis_work1       ;Save check address
    dis_lp1 movf    dis_work1,w     ;Read check address
            movwf   fsr             ;Set check address
            movlw   b'01111111'     ;Set init bit pattern
            movwf   indf            ;Write bit pattern
            incf    dis_work1,f     ;Check addres + 1
            decfsz  dis_lp,f        ;Initial end ?
            goto    dis_lp1         ;Next

            movlw   d'112'          ;Set loop count
            movwf   dis_lp          ;Save loop count
    dis_loop
            movf    tmr0,w          ;Read Random Number
            movwf   dis_row         ;Save random number
            movwf   dis_bit         ;Save random number
            movlw   b'00000111'     ;Set mask pattern
            andwf   dis_bit,f       ;Pick-up bit ID
            btfsc   status,z        ;Bit ID = 0 ?
            incf    dis_bit,f       ;Yes. Bit ID + 1
            movlw   d'3'            ;Set shift count
            movwf   dis_work1       ;Save shift count
    dis_sf_lp
            rrf     dis_row,f       ;Rotate right
            decfsz  dis_work1,f     ;Rotate end ?
            goto    dis_sf_lp       ;No. Next
            movlw   b'00001111'     ;Set mask pattern
            andwf   dis_row,f       ;Pick-up row ID

    dis_row_proc
            movlw   scrnchd         ;Set check head adr
            addwf   dis_row,w       ;Set check adr
            movwf   fsr             ;Set check adr
            movf    indf,w          ;Read check data
            movwf   dis_work1       ;Save check data
            btfsc   status,z        ;All 0 ?(Processed?)
            goto    dis_other_row   ;Yes. Set other row

    dis_bit_proc
            movf    dis_bit,w       ;Set bit ID
            movwf   dis_work2       ;Save bit ID
    dis_lp2 rrf     dis_work1,f     ;Rotate right
            decfsz  dis_work2,f     ;Rotate end ?
            goto    dis_lp2         ;No. Next
            btfss   status,c        ;Bit = 0 ?(Processed?)
            goto    dis_other_bit   ;Yes. Set other bit

            bcf     status,c        ;Clear bit
            movwf   dis_work2       ;Save bit ID
    dis_lp3 rlf     dis_work1,f     ;Rotate left
            decfsz  dis_work2,f     ;Rotate end ?
            goto    dis_lp3         ;No. Next
            movlw   scrnchd         ;Set check head adr
            addwf   dis_row,w       ;Set check adr
            movwf   fsr             ;Set check adr
            movf    dis_work1,w     ;Read check data
            movwf   indf            ;Write check data

            movlw   scrnhd          ;Set screen head adr
            addwf   dis_row,w       ;Set screen adr
            movwf   fsr             ;Set screen adr
            movf    indf,w          ;Read screen data
            movwf   dis_datas       ;Save screen data
            movf    dis_bit,w       ;Set bit ID
            movwf   dis_work2       ;Save bit ID
            decfsz  dis_work2,f     ;Need shift ?
            goto    dis_lp4         ;Yes. Shift proc
    dis_aa  bcf     dis_datas,0     ;Clear bit
            movwf   dis_work2       ;Save bit ID
            decfsz  dis_work2,f     ;Need shift ?
            goto    dis_lp5         ;Yes. Shift proc
    dis_bb  movlw   scrnwhd         ;Set screen work H.A
            addwf   dis_row,w       ;Set screen work adr
            movwf   fsr             ;Set screen work adr
            movf    indf,w          ;Read screen work data
            movwf   dis_dataw       ;Save work data
            movf    dis_bit,w       ;Set bit ID
            movwf   dis_work2       ;Save bit ID
            decfsz  dis_work2,f     ;Need shift ?
            goto    dis_lp6         ;Yes. Shift proc
    dis_cc  movlw   b'00000001'     ;Set mask pattern
            andwf   dis_dataw,f     ;Pick-up data
            bcf     status,c        ;Clear carry bit
            movf    dis_bit,w       ;Set bit ID
            movwf   dis_work2       ;Save bit ID
            decfsz  dis_work2,f     ;Need shift ?
            goto    dis_lp7         ;Yes. Shift proc
    dis_dd  movf    dis_dataw,w     ;Read picked work data
            iorwf   dis_datas,f     ;Set data
            movlw   scrnhd          ;Set screen head adr
            addwf   dis_row,w       ;Set screen adr
            movwf   fsr             ;Set screen adr
            movf    dis_datas,w     ;Set data
            movwf   indf            ;Write data
            call    led_cnt         ;LED control
            call    t100m           ;Wait 100 msec
            decfsz  dis_lp,f        ;Loop end ?
            goto    dis_loop        ;No. Next
            return

    dis_lp4 rrf     dis_datas,f     ;Rotate right
            decfsz  dis_work2,f     ;Rotate end ?
            goto    dis_lp4         ;No. Next
            goto    dis_aa

    dis_lp5 rlf     dis_datas,f     ;Rotate left
            decfsz  dis_work2,f     ;Rotate end ?
            goto    dis_lp5         ;No. Next
            goto    dis_bb

    dis_lp6 rrf     dis_dataw,f     ;Rotate right
            decfsz  dis_work2,f     ;Rotate end ?
            goto    dis_lp6         ;No. Next
            goto    dis_cc

    dis_lp7 rlf     dis_dataw,f     ;Rotate left
            decfsz  dis_work2,f     ;Rotate end ?
            goto    dis_lp7         ;No. Next
            goto    dis_dd

    dis_other_row
            movf    dis_row,w       ;Read row ID
            btfsc   status,z        ;Row ID = 0 ?
            movlw   d'16'           ;Set max row ID
            movwf   dis_row         ;Save row ID
            decf    dis_row,f       ;Row ID - 1
            movlw   scrnchd         ;Set check head adr
            addwf   dis_row,w       ;Set check adr
            movwf   fsr             ;Set check adr
            movf    indf,w          ;Read check data
            movwf   dis_work1       ;Save check data
            goto    dis_row_proc

    dis_other_bit
            decf    dis_bit,f       ;Bit ID - 1
            movf    dis_bit,w       ;Read bit ID
            btfsc   status,z        ;Bit ID = 0 ?
            movlw   d'7'            ;Yes. Set max bit ID
            movwf   dis_bit         ;Save bit ID
            movlw   scrnchd         ;Set check head adr
            addwf   dis_row,w       ;Set check adr
            movwf   fsr             ;Set check adr
            movf    indf,w          ;Read check data
            movwf   dis_work1       ;Save check data
            goto    dis_bit_proc
Explanation The assignment of workarea is done among the 10th line from the 2nd line. In this subroutine, 40h to 4Fh of RAM are used as the check bit table. So, the second half of the common workarea is used as the workarea of this routine. First, the check bit table is initialized(ALL'1'). The number of all the bits(112 bits) is set as the loop count. As the index of the bit, a random number is used. 3 bits of lower are bit index and 4 bits on it are row index. From 1 to 7 is used for bit index. 0 isn't used. The MSB(Most Significant Bit) of the random number isn't used, too. First, it checks the processing situation of the row which the random number specifies with the bit table. It checks a bit if there is '1' where of the confirmed check bit row. It subtracts row index if there is not '1' in the check bit row. It is moved to the most significant row if there is not '1' in the least significant row. It always reaches the row which has '1' if being within 112 loop. It begins bit checking from the bit which is specified by the random number. If the specified bit has processed'0' already, it subtracts bit index. It is moved to the most significant bit if there is not '1' even if it confirms to the least significant bit. It always reaches the bit of '1'. The bit checking uses RRF instruction and it judges a carry bit. When detecting an un-processed bit, it makes a carry bit '0' and it returns to the original position using the RLF instruction. In this condition, it copies the bit which corresponds to the row index and the bit index on to the screen area from the screen workarea. At this time, bit processing is done to rewrite only a corresponding bit. LED control is done every time it rewrites by 1 bit. The shift speed of the display is 100 milliseconds/bit. If changing this timer, the display speed can be changed.