📄 picclock.sdi
字号:
,,,
007E,2044,set_loop,set_loop call chk_hsel ; Check for H12/H24 display change.
007F,1D85,, btfss PORTA,BIT_MSET ; If pin is high then switch is open.
0080,288C,, goto set_mins ; Bit not set, switch closed, set minutes.
0081,1D05,, btfss PORTA,BIT_HSET ; If pin is high then switch is open.
0082,2895,, goto set_hours ; Bit not set, switch closed, set hours.
0083,1C85,, btfss PORTA,BIT_TSET ; If pin is high then switch is open.
0084,287E,, goto set_loop ; Bit not set, switch closed, loop.
,,,
0085,1110,, bcf state,BIT_SET ; Clear the 'set mode' bit.
0086,20DD,, call wr_state ; Update the state output latch.
,,,
0087,0B95,chk_tset_idc,chk_tset_idc decfsz idc,F ; Decrement idc. If zero we can reenable interrupts.
0088,3401,, retlw 1 ; Return without enabling interrupts.
0089,3090,chk_tset_done,chk_tset_done movlw H'90' ; Constant for GIE and T0IE.
008A,008B,, movwf INTCON ; Set interrupt register.
008B,3401,, retlw 1 ; Return.
,,,
008C,0A92,set_mins,set_mins incf mins,F ; Increment minute count.
008D,0812,, movf mins,W ; Get it into W.
008E,3C3C,, sublw D'60' ; Is it 60 (W=60-W)?
008F,1903,, btfsc STATUS,Z ; Test zero flag, skip clear if no set.
0090,0192,, clrf mins ; Clear minutes.
0091,20BF,, call wr_mins ; Write minutes.
,,,
0092,1D85,debounce_mset,debounce_mset btfss PORTA,BIT_MSET ; Wait for MSET button to be released.
0093,2892,, goto debounce_mset ; Loop.
0094,287E,, goto set_loop ; Released so recheck buttons.
,,,
0095,2099,set_hours,set_hours call inc_hours ; Increment hours and display.
0096,1D05,debounce_hset,debounce_hset btfss PORTA,BIT_HSET ; Wait for HSET button to be released.
0097,2896,, goto debounce_hset ; Loop.
0098,287E,, goto set_loop ; Released so recheck buttons.
,,,
,,,;------------------------------------------------------------------------------
,,,; Increment hours, set PM indicator bit as necessary.
,,,
0099,1810,inc_hours,inc_hours btfsc state,BIT_H24 ; 12h display?
009A,28A9,, goto reset_on24 ; No, so we reset when we get to 24.
,,,
009B,0813,reset_on12,reset_on12 movf hours,W ; Get hours
009C,3C0C,, sublw D'12' ; Is it 12 (W=12-W)?
009D,1903,, btfsc STATUS,Z ; Test zero flag, skip clear if no set.
009E,0193,, clrf hours ; Clear hours.
009F,0A93,, incf hours,F ; Increment hours.
00A0,20CE,, call wr_hours ; Write it.
00A1,0813,, movf hours,W ; Get hours
00A2,3C0C,, sublw D'12' ; Is it 12 (W=12-W)?
00A3,1D03,, btfss STATUS,Z ; Test zero flag.
00A4,0008,, return ; Zero not set, so not 12, so return.
00A5,3002,, movlw MASK_PM ; Get PM state bit mask.
00A6,0690,, xorwf state,F ; Toggle PM state bit in state.
00A7,20DD,, call wr_state ; Update state outputs.
00A8,0008,, return ; Return.
,,,
00A9,0A93,reset_on24,reset_on24 incf hours,F ; Incrment hours.
00AA,0813,, movf hours,W ; Get it in W.
00AB,3C18,, sublw D'24' ; Is it 24 (W=24-W)?
00AC,1903,, btfsc STATUS,Z ; Test zero flag, skip clear if no set.
00AD,0193,, clrf hours ; Clear hours 24->0.
00AE,20CE,, call wr_hours ; Write hours to display.
00AF,0008,, return
,,,
,,,;------------------------------------------------------------------------------
,,,; Get seconds value, split to get BCD pair and write to port.
00B0,0811,wr_secs,wr_secs movf secs,W ; Get seconds.
00B1,2100,, call bin2bcd ; Convert to BCD.
00B2,0096,, movwf bcd ; Save result.
00B3,39F0,, andlw 0xF0 ; Mask BCD pair to leave upper digit in W upper nibble.
00B4,380A,, iorlw 0x0A ; Select strobe.
00B5,0086,, movwf PORTB ; Write to PORTB.
00B6,39F0,, andlw 0xF0 ; Clear strobe (by selecting Q0).
00B7,0086,, movwf PORTB ; Write to PORTB.
00B8,0E16,, swapf bcd,W ; Get lower BCD digit in to W upper nibble.
00B9,39F0,, andlw 0xF0 ; Mask of strobe selection bits.
00BA,380C,, iorlw 0x0C ; Set WR strobe.
00BB,0086,, movwf PORTB ; Write to PORTB.
00BC,39F0,, andlw 0xF0 ; Clear strobe.
00BD,0086,, movwf PORTB ; Write to PORTB.
00BE,0008,, return ; Return.
,,,
,,,;------------------------------------------------------------------------------
,,,; Get minutes value, split to get BCD pair and write to port.
00BF,0812,wr_mins,wr_mins movf mins,W ; Get minutes value.
00C0,2100,, call bin2bcd ; Convert to BCD.
00C1,0096,, movwf bcd ; Save result.
00C2,39F0,, andlw 0xF0 ; Mask BCD pair to leave upper digit in W upper nibble.
00C3,3806,, iorlw 0x06 ; Select strobe.
00C4,0086,, movwf PORTB ; Write to PORTB.
00C5,39F0,, andlw 0xF0 ; Clear strobe (by selecting Q0).
00C6,0086,, movwf PORTB ; Write to PORTB.
00C7,0E16,, swapf bcd,W ; Get lower BCD digit in to W upper nibble.
00C8,39F0,, andlw 0xF0 ; Mask of strobe selection bits.
00C9,3808,, iorlw 0x08 ; Set WR strobe.
00CA,0086,, movwf PORTB ; Write to PORTB.
00CB,39F0,, andlw 0xF0 ; Clear strobe.
00CC,0086,, movwf PORTB ; Write to PORTB.
00CD,0008,, return ; Return.
,,,
,,,;------------------------------------------------------------------------------
,,,; Get hours value, split to get BCD pair and write to port.
00CE,0813,wr_hours,wr_hours movf hours,W ; Get hours value/
00CF,2100,, call bin2bcd ; Convert to BCD.
00D0,0096,, movwf bcd ; Save result.
00D1,39F0,, andlw 0xF0 ; Mask BCD pair to leave upper digit in W upper nibble.
00D2,3802,, iorlw 0x02 ; Select strobe.
00D3,0086,, movwf PORTB ; Write to PORTB.
00D4,39F0,, andlw 0xF0 ; Clear strobe (by selecting Q0).
00D5,0086,, movwf PORTB ; Write to PORTB.
00D6,0E16,, swapf bcd,W ; Get lower BCD digit in to W upper nibble.
00D7,39F0,, andlw 0xF0 ; Mask of strobe selection bits.
00D8,3804,, iorlw 0x04 ; Set WR strobe.
00D9,0086,, movwf PORTB ; Write to PORTB.
00DA,39F0,, andlw 0xF0 ; Clear strobe.
00DB,0086,, movwf PORTB ; Write to PORTB.
00DC,0008,, return ; Return.
,,,
,,,;------------------------------------------------------------------------------
,,,; Write state bits to state latch.
00DD,0E10,wr_state,wr_state swapf state,W ; Get state bits in to W<4:1>.
00DE,380E,, iorlw 0x0E ; Set WR strobe.
00DF,0086,, movwf PORTB ; Write to PORTB.
00E0,39F0,, andlw 0xF0 ; Clear strobe by selecting Q0.
00E1,0086,, movwf PORTB ; Write to PORTB.
00E2,0008,, return
,,,
,,,;------------------------------------------------------------------------------
,,,; Routine to convert a binary value (0..63) in to a BCD pair. The result is
,,,; returned in W. The lookup is done as a 'calculated goto' by modifying PCL
,,,; (the lower eight bits of the program counter). PCL is only eight bits wide
,,,; with the top five bits coming from the PCLATH register. We use an ORG
,,,; statement to ensure that addition of the offset (0..63) to the table address
,,,; doesn't overflow the PCL register (any overflow would be lost and would result
,,,; in a jump to some other part of the code).
,,,
0100,,, ORG 0x0100
,,,
0100,018A,bin2bcd,bin2bcd clrf PCLATH ; Clear PCLATH.
0101,140A,, bsf PCLATH,0 ; Set bit zero so that goto yields an
,,, ; address 0x01xx.
0102,393F,, andlw H'3F' ; Ensure we limit lookup.
0103,0782,, addwf PCL,F ; Add offset in W to PCL to calc. goto.
,,,
0104,3400,, retlw 0x00
0105,3401,, retlw 0x01
0106,3402,, retlw 0x02
0107,3403,, retlw 0x03
0108,3404,, retlw 0x04
0109,3405,, retlw 0x05
010A,3406,, retlw 0x06
010B,3407,, retlw 0x07
010C,3408,, retlw 0x08
010D,3409,, retlw 0x09
010E,3410,, retlw 0x10
010F,3411,, retlw 0x11
0110,3412,, retlw 0x12
0111,3413,, retlw 0x13
0112,3414,, retlw 0x14
0113,3415,, retlw 0x15
0114,3416,, retlw 0x16
0115,3417,, retlw 0x17
0116,3418,, retlw 0x18
0117,3419,, retlw 0x19
0118,3420,, retlw 0x20
0119,3421,, retlw 0x21
011A,3422,, retlw 0x22
011B,3423,, retlw 0x23
011C,3424,, retlw 0x24
011D,3425,, retlw 0x25
011E,3426,, retlw 0x26
011F,3427,, retlw 0x27
0120,3428,, retlw 0x28
0121,3429,, retlw 0x29
0122,3430,, retlw 0x30
0123,3431,, retlw 0x31
0124,3432,, retlw 0x32
0125,3433,, retlw 0x33
0126,3434,, retlw 0x34
0127,3435,, retlw 0x35
0128,3436,, retlw 0x36
0129,3437,, retlw 0x37
012A,3438,, retlw 0x38
012B,3439,, retlw 0x39
012C,3440,, retlw 0x40
012D,3441,, retlw 0x41
012E,3442,, retlw 0x42
012F,3443,, retlw 0x43
0130,3444,, retlw 0x44
0131,3445,, retlw 0x45
0132,3446,, retlw 0x46
0133,3447,, retlw 0x47
0134,3448,, retlw 0x48
0135,3449,, retlw 0x49
0136,3450,, retlw 0x50
0137,3451,, retlw 0x51
0138,3452,, retlw 0x52
0139,3453,, retlw 0x53
013A,3454,, retlw 0x54
013B,3455,, retlw 0x55
013C,3456,, retlw 0x56
013D,3457,, retlw 0x57
013E,3458,, retlw 0x58
013F,3459,, retlw 0x59
0140,3460,, retlw 0x60
0141,3461,, retlw 0x61
0142,3462,, retlw 0x62
0143,3463,, retlw 0x63
,,,
,,, END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -