2 ; Firmware for the TeleTerra ground station board for TeleMetrum,
3 ; see http://altusmetrum.org/TeleTerra for more information.
5 ; Copyright © 2009 Bdale Garbee <bdale@gag.com>
7 ; This program is free software; you can redistribute it and/or modify
8 ; it under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation; version 2 of the License.
11 ; This program is distributed in the hope that it will be useful, but
12 ; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ; General Public License for more details.
16 ; You should have received a copy of the GNU General Public License along
17 ; with this program; if not, write to the Free Software Foundation, Inc.,
18 ; 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 ;************************************************************
21 ; Processor: PIC16F886 using internal oscillator
22 ;************************************************************
24 ; FIXME - more or less cloned from clock4robert project, not ready for use yet!
26 LIST P=18F886, R=DEC ; Use the PIC18F4550 and decimal system
28 #include "p16f886.inc" ; Include header file
30 __config 0x300001, 0x22
31 __config 0x300003, 0xe
32 __config 0x300006, 0x81
34 CBLOCK 0x20 ; Declare variable addresses starting at 0x20
35 Loop1,Loop2,Loop3,Counter
57 CLRF PORTA ; Initialize port A
58 CLRF PORTD ; Initialize port D
59 CLRF PORTE ; Initialize port E
61 CLRF TRISA ; All pins port A output
62 CLRF TRISD ; All pins port D output
63 CLRF TRISE ; All pins port E output
71 CLRF TMR0H ; clear timer 0
74 ; this works out to about 1.4 seconds per tick
75 ; MOVLW b'10000111' ; enable 16 bit timer, 256:1 prescaler
76 ; this works out to about 350ms per tick
77 ; MOVLW b'10000101' ; enable 16 bit timer, 64:1 prescaler
78 ; this works out to about 10.4ms per tick, or 91.6hz
79 ; MOVLW b'10000000' ; enable 16 bit timer, 2:1 prescaler
80 ; this works out to 5.46ms per tick, 183.32hz
81 MOVLW b'10001000' ; enable 16 bit timer, no prescaler
84 BCF INTCON, TMR0IF ; clear Timer0 interrupt flag
85 BSF INTCON, TMR0IE ; enable Timer0 interrupt
86 BSF INTCON, GIE ; enable interrupts
88 ; ------------------------
89 ; FUNCTION OF PORT A PINS
90 ; ------------------------
93 ; MOVWF CMCON ; Comparators off, all pins digital I/O
98 Main CALL LpmOn ; light PM
100 CALL LsaOn ; light segment A
101 CALL LsbOn ; light segment B
102 CALL LscOn ; light segment C
103 CALL LsdOn ; light segment D
104 CALL LseOn ; light segment E
105 CALL LsfOn ; light segment F
106 CALL LsgOn ; light segment G
113 CALL LcOff ; colon off
127 CALL LcOff ; colon off
163 ; control digit segment A
170 ; control digit segment B
177 ; control digit segment C
184 ; control digit segment D
191 ; control digit segment E
198 ; control digit segment F
205 ; control digit segment G
212 ; control the "AM" LED
219 ; control the "PM" LED
226 ; control the "colon" LED
233 ; control the "alarm" LED
262 ; High priority interrupt service route
265 BCF INTCON, TMR0IF ; clear Timer0 interrupt flag
267 BTFSC Counter,6 ; test bit 6
269 CALL LaOff ; turn alarm LED off
272 CALL LaOn ; turn alarm LED on