; FIXME - more or less cloned from clock4robert project, not ready for use yet!
- LIST P=18F886, R=DEC ; Use the PIC18F4550 and decimal system
+ LIST P=16F886, R=DEC ; Use the PIC18F4550 and decimal system
#include "p16f886.inc" ; Include header file
- __config 0x300001, 0x22
- __config 0x300003, 0xe
- __config 0x300006, 0x81
-
- CBLOCK 0x20 ; Declare variable addresses starting at 0x20
- Loop1,Loop2,Loop3,Counter
- ENDC
-
-; -----------
-; Vectors
-; -----------
-
- ORG 0x0800
- GOTO Start
-
- ORG 0x0808
- CALL H_PRIO_ISR
- RETFIE
-
- ORG 0x0818
- RETFIE
-
-; -----------
-; INITIALIZE
-; -----------
-
-Start
- CLRF PORTA ; Initialize port A
- CLRF PORTD ; Initialize port D
- CLRF PORTE ; Initialize port E
+; __config 0x300001, 0x22
+; __config 0x300003, 0xe
+; __config 0x300006, 0x81
+;
+; CBLOCK 0x20 ; Declare variable addresses starting at 0x20
+; Loop1,Loop2,Loop3,Counter
+; ENDC
+;
+; ; -----------
+; ; Vectors
+; ; -----------
+;
+; ORG 0x0800
+; GOTO Start
+;
+; ORG 0x0808
+; CALL H_PRIO_ISR
+; RETFIE
+;
+; ORG 0x0818
+; RETFIE
+;
+; ; -----------
+; ; INITIALIZE
+; ; -----------
+;
+; Start
+; CLRF PORTA ; Initialize port A
+; CLRF PORTD ; Initialize port D
+; CLRF PORTE ; Initialize port E
+;
+; CLRF TRISA ; All pins port A output
+; CLRF TRISD ; All pins port D output
+; CLRF TRISE ; All pins port E output
+;
+; ; CLRF WDTCON
+;
+; ; -----------
+; ; Timer0
+; ; -----------
+;
+; CLRF TMR0H ; clear timer 0
+; CLRF TMR0L
+;
+; ; this works out to about 1.4 seconds per tick
+; ; MOVLW b'10000111' ; enable 16 bit timer, 256:1 prescaler
+; ; this works out to about 350ms per tick
+; ; MOVLW b'10000101' ; enable 16 bit timer, 64:1 prescaler
+; ; this works out to about 10.4ms per tick, or 91.6hz
+; ; MOVLW b'10000000' ; enable 16 bit timer, 2:1 prescaler
+; ; this works out to 5.46ms per tick, 183.32hz
+; MOVLW b'10001000' ; enable 16 bit timer, no prescaler
+; MOVWF T0CON
+;
+; BCF INTCON, TMR0IF ; clear Timer0 interrupt flag
+; BSF INTCON, TMR0IE ; enable Timer0 interrupt
+; BSF INTCON, GIE ; enable interrupts
+;
+; ; ------------------------
+; ; FUNCTION OF PORT A PINS
+; ; ------------------------
+; ;
+; ; MOVLW 7
+; ; MOVWF CMCON ; Comparators off, all pins digital I/O
+; ;
+; ; ----------
+; ; MAIN LOOP
+; ; ----------
+; Main CALL LpmOn ; light PM
+; CALL LamOff
+; CALL LsaOn ; light segment A
+; CALL LsbOn ; light segment B
+; CALL LscOn ; light segment C
+; CALL LsdOn ; light segment D
+; CALL LseOn ; light segment E
+; CALL LsfOn ; light segment F
+; CALL LsgOn ; light segment G
+; CALL LcOn ; colon on
+; CALL Drv0On
+; CALL Drv1Off
+; CALL Drv2Off
+; CALL Drv3Off
+; CALL delay
+; CALL LcOff ; colon off
+; CALL Drv0Off
+; CALL Drv1On
+; CALL Drv2Off
+; CALL Drv3Off
+; CALL delay
+; CALL LcOn ; colon on
+; CALL LamOn
+; CALL LpmOff
+; CALL Drv0Off
+; CALL Drv1Off
+; CALL Drv2On
+; CALL Drv3Off
+; CALL delay
+; CALL LcOff ; colon off
+; CALL Drv0Off
+; CALL Drv1Off
+; CALL Drv2Off
+; CALL Drv3On
+; CALL delay
+; GOTO Main
+;
+; ; digit select 0
+; Drv0On BSF LATA,2
+; RETURN
+;
+; Drv0Off BCF LATA,2
+; RETURN
+;
+; ; digit select 1
+; Drv1On BSF LATA,3
+; RETURN
+;
+; Drv1Off BCF LATA,3
+; RETURN
+;
+; ; digit select 2
+; Drv2On BSF LATA,4
+; RETURN
+;
+; Drv2Off BCF LATA,4
+; RETURN
+;
+; ; digit select 3
+; Drv3On BSF LATA,5
+; RETURN
+;
+; Drv3Off BCF LATA,5
+; RETURN
+;
+; ; control digit segment A
+; LsaOn BSF LATD,0
+; RETURN
+;
+; LsaOff BCF LATD,0
+; RETURN
+;
+; ; control digit segment B
+; LsbOn BSF LATD,1
+; RETURN
+;
+; LsbOff BCF LATD,1
+; RETURN
+;
+; ; control digit segment C
+; LscOn BSF LATD,2
+; RETURN
+;
+; LscOff BCF LATD,2
+; RETURN
+;
+; ; control digit segment D
+; LsdOn BSF LATD,3
+; RETURN
+;
+; LsdOff BCF LATD,3
+; RETURN
+;
+; ; control digit segment E
+; LseOn BSF LATD,4
+; RETURN
+;
+; LseOff BCF LATD,4
+; RETURN
+;
+; ; control digit segment F
+; LsfOn BSF LATD,5
+; RETURN
+;
+; LsfOff BCF LATD,5
+; RETURN
+;
+; ; control digit segment G
+; LsgOn BSF LATD,6
+; RETURN
+;
+; LsgOff BCF LATD,6
+; RETURN
+;
+; ; control the "AM" LED
+; LamOn BSF LATE,1
+; RETURN
+;
+; LamOff BCF LATE,1
+; RETURN
+;
+; ; control the "PM" LED
+; LpmOn BSF LATE,2
+; RETURN
+;
+; LpmOff BCF LATE,2
+; RETURN
+;
+; ; control the "colon" LED
+; LcOn BSF LATD,7
+; RETURN
+;
+; LcOff BCF LATD,7
+; RETURN
+;
+; ; control the "alarm" LED
+; LaOn BSF LATE,0
+; RETURN
+;
+; LaOff BCF LATE,0
+; RETURN
+;
+; ; ---------------
+; ; DELAY 0.5 SEC
+; ; ---------------
+; ;
+; ;delay MOVLW 20
+; delay MOVLW 10
+; MOVWF Loop1
+; Outer MOVLW 250
+; MOVWF Loop2
+; Middle MOVLW 239
+; MOVWF Loop3
+; Inner NOP
+; NOP
+; DECFSZ Loop3,F
+; GOTO Inner
+; DECFSZ Loop2,F
+; GOTO Middle
+; DECFSZ Loop1,F
+; GOTO Outer
+; RETURN
+;
+; ; ---------------
+; ; High priority interrupt service route
+; ; ---------------
+; H_PRIO_ISR
+; BCF INTCON, TMR0IF ; clear Timer0 interrupt flag
+; INCF Counter,1
+; BTFSC Counter,6 ; test bit 6
+; GOTO TurnItOn
+; CALL LaOff ; turn alarm LED off
+; GOTO End_ISR
+; TurnItOn
+; CALL LaOn ; turn alarm LED on
+; End_ISR
+; RETURN
- CLRF TRISA ; All pins port A output
- CLRF TRISD ; All pins port D output
- CLRF TRISE ; All pins port E output
-
-; CLRF WDTCON
-
-; -----------
-; Timer0
-; -----------
-
- CLRF TMR0H ; clear timer 0
- CLRF TMR0L
-
-; this works out to about 1.4 seconds per tick
-; MOVLW b'10000111' ; enable 16 bit timer, 256:1 prescaler
-; this works out to about 350ms per tick
-; MOVLW b'10000101' ; enable 16 bit timer, 64:1 prescaler
-; this works out to about 10.4ms per tick, or 91.6hz
-; MOVLW b'10000000' ; enable 16 bit timer, 2:1 prescaler
-; this works out to 5.46ms per tick, 183.32hz
- MOVLW b'10001000' ; enable 16 bit timer, no prescaler
- MOVWF T0CON
-
- BCF INTCON, TMR0IF ; clear Timer0 interrupt flag
- BSF INTCON, TMR0IE ; enable Timer0 interrupt
- BSF INTCON, GIE ; enable interrupts
-
-; ------------------------
-; FUNCTION OF PORT A PINS
-; ------------------------
-;
-; MOVLW 7
-; MOVWF CMCON ; Comparators off, all pins digital I/O
-;
-; ----------
-; MAIN LOOP
-; ----------
-Main CALL LpmOn ; light PM
- CALL LamOff
- CALL LsaOn ; light segment A
- CALL LsbOn ; light segment B
- CALL LscOn ; light segment C
- CALL LsdOn ; light segment D
- CALL LseOn ; light segment E
- CALL LsfOn ; light segment F
- CALL LsgOn ; light segment G
- CALL LcOn ; colon on
- CALL Drv0On
- CALL Drv1Off
- CALL Drv2Off
- CALL Drv3Off
- CALL delay
- CALL LcOff ; colon off
- CALL Drv0Off
- CALL Drv1On
- CALL Drv2Off
- CALL Drv3Off
- CALL delay
- CALL LcOn ; colon on
- CALL LamOn
- CALL LpmOff
- CALL Drv0Off
- CALL Drv1Off
- CALL Drv2On
- CALL Drv3Off
- CALL delay
- CALL LcOff ; colon off
- CALL Drv0Off
- CALL Drv1Off
- CALL Drv2Off
- CALL Drv3On
- CALL delay
- GOTO Main
-
-; digit select 0
-Drv0On BSF LATA,2
- RETURN
-
-Drv0Off BCF LATA,2
- RETURN
-
-; digit select 1
-Drv1On BSF LATA,3
- RETURN
-
-Drv1Off BCF LATA,3
- RETURN
-
-; digit select 2
-Drv2On BSF LATA,4
- RETURN
-
-Drv2Off BCF LATA,4
- RETURN
-
-; digit select 3
-Drv3On BSF LATA,5
- RETURN
-
-Drv3Off BCF LATA,5
- RETURN
-
-; control digit segment A
-LsaOn BSF LATD,0
- RETURN
-
-LsaOff BCF LATD,0
- RETURN
-
-; control digit segment B
-LsbOn BSF LATD,1
- RETURN
-
-LsbOff BCF LATD,1
- RETURN
-
-; control digit segment C
-LscOn BSF LATD,2
- RETURN
-
-LscOff BCF LATD,2
- RETURN
-
-; control digit segment D
-LsdOn BSF LATD,3
- RETURN
-
-LsdOff BCF LATD,3
- RETURN
-
-; control digit segment E
-LseOn BSF LATD,4
- RETURN
-
-LseOff BCF LATD,4
- RETURN
-
-; control digit segment F
-LsfOn BSF LATD,5
- RETURN
-
-LsfOff BCF LATD,5
- RETURN
-
-; control digit segment G
-LsgOn BSF LATD,6
- RETURN
-
-LsgOff BCF LATD,6
- RETURN
-
-; control the "AM" LED
-LamOn BSF LATE,1
- RETURN
-
-LamOff BCF LATE,1
- RETURN
-
-; control the "PM" LED
-LpmOn BSF LATE,2
- RETURN
-
-LpmOff BCF LATE,2
- RETURN
-
-; control the "colon" LED
-LcOn BSF LATD,7
- RETURN
-
-LcOff BCF LATD,7
- RETURN
-
-; control the "alarm" LED
-LaOn BSF LATE,0
- RETURN
-
-LaOff BCF LATE,0
- RETURN
-
-; ---------------
-; DELAY 0.5 SEC
-; ---------------
-;
-;delay MOVLW 20
-delay MOVLW 10
- MOVWF Loop1
-Outer MOVLW 250
- MOVWF Loop2
-Middle MOVLW 239
- MOVWF Loop3
-Inner NOP
- NOP
- DECFSZ Loop3,F
- GOTO Inner
- DECFSZ Loop2,F
- GOTO Middle
- DECFSZ Loop1,F
- GOTO Outer
- RETURN
-
-; ---------------
-; High priority interrupt service route
-; ---------------
-H_PRIO_ISR
- BCF INTCON, TMR0IF ; clear Timer0 interrupt flag
- INCF Counter,1
- BTFSC Counter,6 ; test bit 6
- GOTO TurnItOn
- CALL LaOff ; turn alarm LED off
- GOTO End_ISR
-TurnItOn
- CALL LaOn ; turn alarm LED on
-End_ISR
- RETURN
-
- END
+ END
refdes=S2
T 69200 58400 5 10 0 0 0 0 1
device=SWITCH_PUSHBUTTON_NO
+T 68800 57800 5 10 0 1 0 0 1
+value=spst no momentary
}
C 67600 57400 1 0 0 switch-spst-1.sym
{
device=SPST
T 67500 57100 5 10 1 1 0 0 1
refdes=S3
+T 67600 57400 5 10 0 1 0 0 1
+value=spst slide
}
C 53600 58100 1 0 1 led.sym
{
footprint=1206
T 54000 57900 5 10 1 1 0 6 1
refdes=R3
+T 54200 57900 5 10 1 1 0 0 1
+value=270
}
C 56200 57700 1 0 1 resistor.sym
{
refdes=R4
T 56205 57700 5 10 0 1 0 6 1
footprint=1206
+T 55900 57500 5 10 1 1 0 0 1
+value=270
}
C 54500 56900 1 0 1 resistor.sym
{
refdes=R5
T 54505 56900 5 10 0 1 0 6 1
footprint=1206
+T 54200 56700 5 10 1 1 0 0 1
+value=270
}
C 56200 56500 1 0 1 resistor.sym
{
refdes=R6
T 56205 56500 5 10 0 1 0 6 1
footprint=1206
+T 55900 56300 5 10 1 1 0 0 1
+value=270
}
T 69300 57500 9 10 1 0 0 0 1
mode
refdes=S1
T 68000 59600 5 10 0 0 0 0 1
device=SWITCH_PUSHBUTTON_NO
+T 67600 59000 5 10 0 1 0 0 1
+value=spst no momentary
}
C 69900 56900 1 0 0 gnd-1.sym
T 68100 58700 9 10 1 0 0 0 1
N 58600 57000 54500 57000 4
N 58600 57800 56200 57800 4
N 58600 58200 54500 58200 4
-N 65000 58200 71000 58200 4
+N 65000 58200 71100 58200 4
{
T 65900 58300 5 10 1 1 0 0 1
netname=pwm_backlight
device=MCP1825S
T 68900 53800 5 10 1 1 0 6 1
refdes=U2
+T 67500 52800 5 10 0 1 0 0 1
+footprint=TO220
}
N 73100 58800 73100 59200 4
C 70900 52200 1 0 0 gnd-1.sym