From cd34b27818256c0cacb301927c49f03746ccf47b Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Tue, 24 Nov 2009 07:28:13 -0700 Subject: [PATCH] move from assembler to sdcc for program .. just a skeleton now! --- Makefile | 13 ++- teleterra.asm | 276 ------------------------------------------- teleterra.c | 316 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 326 insertions(+), 279 deletions(-) delete mode 100644 teleterra.asm create mode 100644 teleterra.c diff --git a/Makefile b/Makefile index 9036f54..16b1615 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,15 @@ hw: drc partslist sw: teleterra.hex -teleterra.hex: teleterra.asm - gpasm teleterra.asm +CC= sdcc +CFLAGS= -mpic14 -p16f886 +LDFLAGS= + +teleterra.o: teleterra.c + $(CC) -c $(CFLAGS) $< + +teleterra.hex: teleterra.o + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ teleterra.o drc: teleterra.sch -gnetlist -g drc2 teleterra.sch -o teleterra.drc @@ -42,5 +49,5 @@ clean: rm -f *.bom *.drc *.log *~ teleterra.ps *.gbr *.cnc *bak* *- *.zip rm -f *.net *.xy *.cmd *.png partslist rm -f *.partslist *.new.pcb *.unsorted - rm -f *.hex *.cod *.lst + rm -f *.hex *.cod *.lst *.ps *.o *.asm diff --git a/teleterra.asm b/teleterra.asm deleted file mode 100644 index ca459ad..0000000 --- a/teleterra.asm +++ /dev/null @@ -1,276 +0,0 @@ -; -; Firmware for the TeleTerra ground station board for TeleMetrum, -; see http://altusmetrum.org/TeleTerra for more information. -; -; Copyright © 2009 Bdale Garbee -; -; This program is free software; you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation; version 2 of the License. -; -; This program is distributed in the hope that it will be useful, but -; WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; General Public License for more details. -; -; You should have received a copy of the GNU General Public License along -; with this program; if not, write to the Free Software Foundation, Inc., -; 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -; -;************************************************************ -; Processor: PIC16F886 using internal oscillator -;************************************************************ - -; FIXME - more or less cloned from clock4robert project, not ready for use yet! - - 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 -; -; 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 diff --git a/teleterra.c b/teleterra.c new file mode 100644 index 0000000..f5b3688 --- /dev/null +++ b/teleterra.c @@ -0,0 +1,316 @@ +// +// Firmware for the TeleTerra ground station board for TeleMetrum, +// see http://altusmetrum.org/TeleTerra for more information. +// +// Copyright © 2009 Bdale Garbee +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +// +//************************************************************ +// Processor: PIC16F886 using internal oscillator +//************************************************************ + +// FIXME - cloned from clock4robert project, not ready for use yet! + +#include "pic16f886.h" +// #include "signal.h" // interrupt handler / signal techniques + + +// FIXME - these are probably not correct! +code char at _CONFIG1 conf1 = 0x22; // select HS OSC +code char at _CONFIG2 conf2 = 0x0e; // disable WDT + +#define LED_TRIS TRISA7 +#define LED_PIN RA7 + +// a simple delay function +void delay_ms(long ms) +{ + long i; + + while (ms--) + for (i=0; i < 330; i++) + ; +} + + +void main() +{ + + // set pins to output to wiggle LEDs + LED_TRIS = 0; + +// // Enable high and low priority interrupts +// RCON = 0; +// RCONbits.IPEN = 1; +// +// // Configure timer0 +// T0CON = 0x88; // enable 16 bit timer, no prescaler +// +// // enable timer0 interrupt as a high priority source +// INTCON2bits.TMR0IP = 1; +// INTCONbits.TMR0IE = 1; +// +// // Enable interrupts +// INTCONbits.GIE = 1; + + // sit in an endless loop blinking the alarm led + for (;;) + { + LED_PIN = 0; + delay_ms(250); + LED_PIN = 1; + delay_ms(250); + } +} + +// ; ; ----------- +// ; ; 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 +// +// END -- 2.30.2