From: ian Date: Sun, 12 Sep 2004 15:47:38 +0000 (+0000) Subject: flasher replaced with funky flasher X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=67616a9a3c69a516a9fa14bfc2c5968b5b4355c4;p=trains.git flasher replaced with funky flasher --- diff --git a/iwjpictest/copybits.asm b/iwjpictest/copybits.asm index 1cfa1d3..cc03d0f 100644 --- a/iwjpictest/copybits.asm +++ b/iwjpictest/copybits.asm @@ -17,78 +17,77 @@ __config _CONFIG7L, 0xff __config _CONFIG7H, 0xff -ACCSFR equ 0x0f00 +COUNTFAST equ 0x00 +COUNTMEDIUM equ 0x01 +COUNTSLOW equ 0x02 -COUNTINNER equ 0x00 -COUNTOUTER equ 0x02 - -OUTEREXP equ 7 ; 2^7 * 2.6ms = 332ms +SLOWEXP equ 2 ; 2^1 * 40ms = 80ms ; we always leave each loop when its counter has reached 0, so on ; entry we assume it's already 0. For the loops which want to ; count all the way (256 iterations) that's good. start - bcf TRISA, 0, 0 ; enable flasher output - movlw 0x07 ; turn off A-to-D so we get - movwf ADCON1, 0 ; digital inputs on RA0-3 (AN0-3) - bcf TRISD, 4, 0 ; enable output D - movlw 0x1f ; enable outputs E,F,G - movwf TRISC, 0 ; (RC7,6,5) - loop - btg LATA, 0, 0 + call red + call green + call black + + call red + call green + call red + call green + call black + + call red + call green + call red + call green + call red + call green + call black + goto loop + +red + bcf TRISD, 2, 0 ; enable flasher output + bcf LATD, 2, 0 ; set to low + goto delay + +green + bcf TRISD, 2, 0 ; enable flasher output + bsf LATD, 2, 0 ; set to high + goto delay +black + bsf TRISD, 2, 0 ; disable flasher output + call delay + goto delay + +delay ; set a bit which says how fast the led ; should flash and count down from 2^(that bit) - bsf COUNTOUTER, OUTEREXP, 0 -delayouter_loop - -delayinner_loop - -copybit_mi macro sourcereg, sourcebitno, destreg, destbitvals, xorinv - movf destreg, 0, 0 ; read output latch - andlw ~destbitvals ; mask out output bit - btfsc sourcereg, sourcebitno, 0 ; skip if input clear - iorlw destbitvals ; add output bit - xorlw xorinv ; invert? - movwf destreg, 0 ; write output latch - endm ; (6cy total) - -copybiti macro sreg, sbitno, dreg, dbitvals - copybit_mi sreg, sbitno, dreg, dbitvals, dbitvals - endm - -copybit macro sreg, sbitno, dreg, dbitvals - copybit_mi sreg, sbitno, dreg, dbitvals, 0 - endm - - copybiti PORTB, 5, TRISA, 0x06 ; C enable - copybit PORTB, 4, PORTA, 0x06 ; C data - copybiti PORTB, 3, TRISA, 0x18 ; B enable - copybit PORTB, 2, PORTA, 0x18 ; B data - copybiti PORTB, 1, TRISA, 0x20 ; A enable - copybiti PORTB, 1, TRISE, 0x01 ; A enable - copybit PORTB, 0, PORTA, 0x20 ; A data - copybit PORTB, 0, PORTE, 0x01 ; A data - - copybiti PORTA, 6, PORTD, 0x10 ; D - copybiti PORTC, 0, PORTC, 0x80 ; E - copybiti PORTC, 1, PORTC, 0x40 ; F - copybiti PORTC, 2, PORTC, 0x20 ; G - ; 12 x copybit @6 = 48cy - - decfsz COUNTINNER, 1, 0 ; 1 cycle - goto delayinner_loop ; 2 cycles (skipped or not) -; exited delayinner_loop ; total: 51cy * 256 = 13056cy + bsf COUNTSLOW, SLOWEXP, 0 +delayslow_loop + +delaymedium_loop + +delayfast_loop + decfsz COUNTFAST, 1, 0 ; 1 cycle + goto delayfast_loop ; 2 cycles (skipped or not) +; exited delayfast_loop ; total: 3 * 256 = 768 cycles + + + decfsz COUNTMEDIUM, 1, 0 ; 1 cycle + goto delaymedium_loop ; 2 cycles (skipped or not) +; exited delaymedium_loop ; total: ~198000 cycles ; each cycle 0.2us - ; so each inner loop is ~2.6ms + ; so each medium loop is ~40ms - decfsz COUNTOUTER, 1, 0 - goto delayouter_loop -; exited delayouter_loop + decfsz COUNTSLOW, 1, 0 + goto delayslow_loop +; exited delayslow_loop - goto loop + return end diff --git a/iwjpictest/flash-all.asm b/iwjpictest/flash-all.asm deleted file mode 100644 index 049d272..0000000 --- a/iwjpictest/flash-all.asm +++ /dev/null @@ -1,65 +0,0 @@ -; - - include /usr/share/gputils/header/p18f458.inc - -; __config _CONFIG1L, 0xff - __config _CONFIG1H, _OSCS_OFF_1H & _ECIO_OSC_1H - __config _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_45_2L - __config _CONFIG2H, _WDT_OFF_2H -; __config _CONFIG3L, 0xff -; __config _CONFIG3H, 0xff - __config _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVR_ON_4L -; __config _CONFIG4H, 0xff - __config _CONFIG5L, 0xff - __config _CONFIG5H, 0xff - __config _CONFIG6L, 0xff - __config _CONFIG6H, 0xff - __config _CONFIG7L, 0xff - __config _CONFIG7H, 0xff - -ACCSFR equ 0x0f00 - -COUNTFAST equ 0x00 -COUNTMEDIUM equ 0x01 -COUNTSLOW equ 0x02 - -SLOWEXP equ 3 ; 2^3 * 40ms = 320ms - -; we always leave each loop when its counter has reached 0, so on -; entry we assume it's already 0. For the loops which want to -; count all the way (256 iterations) that's good. - -start - bcf TRISA, 0, 0 - bcf TRISD, 7, 0 -loop - btg LATA, 0, 0 - btg LATD, 7, 0 - - ; set a bit which says how fast the led - ; should flash and count down from 2^(that bit) - bsf COUNTSLOW, SLOWEXP, 0 -delayslow_loop - -delaymedium_loop - -delayfast_loop - decfsz COUNTFAST, 1, 0 ; 1 cycle - goto delayfast_loop ; 2 cycles (skipped or not) -; exited delayfast_loop ; total: 3 * 256 = 768 cycles - - - decfsz COUNTMEDIUM, 1, 0 ; 1 cycle - goto delaymedium_loop ; 2 cycles (skipped or not) -; exited delaymedium_loop ; total: ~198000 cycles - - ; each cycle 0.2us - ; so each medium loop is ~40ms - - decfsz COUNTSLOW, 1, 0 - goto delayslow_loop -; exited delayslow_loop - - goto loop - - end diff --git a/iwjpictest/flasher.asm b/iwjpictest/flasher.asm index 1cfa1d3..cc03d0f 100644 --- a/iwjpictest/flasher.asm +++ b/iwjpictest/flasher.asm @@ -17,78 +17,77 @@ __config _CONFIG7L, 0xff __config _CONFIG7H, 0xff -ACCSFR equ 0x0f00 +COUNTFAST equ 0x00 +COUNTMEDIUM equ 0x01 +COUNTSLOW equ 0x02 -COUNTINNER equ 0x00 -COUNTOUTER equ 0x02 - -OUTEREXP equ 7 ; 2^7 * 2.6ms = 332ms +SLOWEXP equ 2 ; 2^1 * 40ms = 80ms ; we always leave each loop when its counter has reached 0, so on ; entry we assume it's already 0. For the loops which want to ; count all the way (256 iterations) that's good. start - bcf TRISA, 0, 0 ; enable flasher output - movlw 0x07 ; turn off A-to-D so we get - movwf ADCON1, 0 ; digital inputs on RA0-3 (AN0-3) - bcf TRISD, 4, 0 ; enable output D - movlw 0x1f ; enable outputs E,F,G - movwf TRISC, 0 ; (RC7,6,5) - loop - btg LATA, 0, 0 + call red + call green + call black + + call red + call green + call red + call green + call black + + call red + call green + call red + call green + call red + call green + call black + goto loop + +red + bcf TRISD, 2, 0 ; enable flasher output + bcf LATD, 2, 0 ; set to low + goto delay + +green + bcf TRISD, 2, 0 ; enable flasher output + bsf LATD, 2, 0 ; set to high + goto delay +black + bsf TRISD, 2, 0 ; disable flasher output + call delay + goto delay + +delay ; set a bit which says how fast the led ; should flash and count down from 2^(that bit) - bsf COUNTOUTER, OUTEREXP, 0 -delayouter_loop - -delayinner_loop - -copybit_mi macro sourcereg, sourcebitno, destreg, destbitvals, xorinv - movf destreg, 0, 0 ; read output latch - andlw ~destbitvals ; mask out output bit - btfsc sourcereg, sourcebitno, 0 ; skip if input clear - iorlw destbitvals ; add output bit - xorlw xorinv ; invert? - movwf destreg, 0 ; write output latch - endm ; (6cy total) - -copybiti macro sreg, sbitno, dreg, dbitvals - copybit_mi sreg, sbitno, dreg, dbitvals, dbitvals - endm - -copybit macro sreg, sbitno, dreg, dbitvals - copybit_mi sreg, sbitno, dreg, dbitvals, 0 - endm - - copybiti PORTB, 5, TRISA, 0x06 ; C enable - copybit PORTB, 4, PORTA, 0x06 ; C data - copybiti PORTB, 3, TRISA, 0x18 ; B enable - copybit PORTB, 2, PORTA, 0x18 ; B data - copybiti PORTB, 1, TRISA, 0x20 ; A enable - copybiti PORTB, 1, TRISE, 0x01 ; A enable - copybit PORTB, 0, PORTA, 0x20 ; A data - copybit PORTB, 0, PORTE, 0x01 ; A data - - copybiti PORTA, 6, PORTD, 0x10 ; D - copybiti PORTC, 0, PORTC, 0x80 ; E - copybiti PORTC, 1, PORTC, 0x40 ; F - copybiti PORTC, 2, PORTC, 0x20 ; G - ; 12 x copybit @6 = 48cy - - decfsz COUNTINNER, 1, 0 ; 1 cycle - goto delayinner_loop ; 2 cycles (skipped or not) -; exited delayinner_loop ; total: 51cy * 256 = 13056cy + bsf COUNTSLOW, SLOWEXP, 0 +delayslow_loop + +delaymedium_loop + +delayfast_loop + decfsz COUNTFAST, 1, 0 ; 1 cycle + goto delayfast_loop ; 2 cycles (skipped or not) +; exited delayfast_loop ; total: 3 * 256 = 768 cycles + + + decfsz COUNTMEDIUM, 1, 0 ; 1 cycle + goto delaymedium_loop ; 2 cycles (skipped or not) +; exited delaymedium_loop ; total: ~198000 cycles ; each cycle 0.2us - ; so each inner loop is ~2.6ms + ; so each medium loop is ~40ms - decfsz COUNTOUTER, 1, 0 - goto delayouter_loop -; exited delayouter_loop + decfsz COUNTSLOW, 1, 0 + goto delayslow_loop +; exited delayslow_loop - goto loop + return end diff --git a/iwjpictest/serialloop.asm b/iwjpictest/serialloop.asm index 1cfa1d3..cc03d0f 100644 --- a/iwjpictest/serialloop.asm +++ b/iwjpictest/serialloop.asm @@ -17,78 +17,77 @@ __config _CONFIG7L, 0xff __config _CONFIG7H, 0xff -ACCSFR equ 0x0f00 +COUNTFAST equ 0x00 +COUNTMEDIUM equ 0x01 +COUNTSLOW equ 0x02 -COUNTINNER equ 0x00 -COUNTOUTER equ 0x02 - -OUTEREXP equ 7 ; 2^7 * 2.6ms = 332ms +SLOWEXP equ 2 ; 2^1 * 40ms = 80ms ; we always leave each loop when its counter has reached 0, so on ; entry we assume it's already 0. For the loops which want to ; count all the way (256 iterations) that's good. start - bcf TRISA, 0, 0 ; enable flasher output - movlw 0x07 ; turn off A-to-D so we get - movwf ADCON1, 0 ; digital inputs on RA0-3 (AN0-3) - bcf TRISD, 4, 0 ; enable output D - movlw 0x1f ; enable outputs E,F,G - movwf TRISC, 0 ; (RC7,6,5) - loop - btg LATA, 0, 0 + call red + call green + call black + + call red + call green + call red + call green + call black + + call red + call green + call red + call green + call red + call green + call black + goto loop + +red + bcf TRISD, 2, 0 ; enable flasher output + bcf LATD, 2, 0 ; set to low + goto delay + +green + bcf TRISD, 2, 0 ; enable flasher output + bsf LATD, 2, 0 ; set to high + goto delay +black + bsf TRISD, 2, 0 ; disable flasher output + call delay + goto delay + +delay ; set a bit which says how fast the led ; should flash and count down from 2^(that bit) - bsf COUNTOUTER, OUTEREXP, 0 -delayouter_loop - -delayinner_loop - -copybit_mi macro sourcereg, sourcebitno, destreg, destbitvals, xorinv - movf destreg, 0, 0 ; read output latch - andlw ~destbitvals ; mask out output bit - btfsc sourcereg, sourcebitno, 0 ; skip if input clear - iorlw destbitvals ; add output bit - xorlw xorinv ; invert? - movwf destreg, 0 ; write output latch - endm ; (6cy total) - -copybiti macro sreg, sbitno, dreg, dbitvals - copybit_mi sreg, sbitno, dreg, dbitvals, dbitvals - endm - -copybit macro sreg, sbitno, dreg, dbitvals - copybit_mi sreg, sbitno, dreg, dbitvals, 0 - endm - - copybiti PORTB, 5, TRISA, 0x06 ; C enable - copybit PORTB, 4, PORTA, 0x06 ; C data - copybiti PORTB, 3, TRISA, 0x18 ; B enable - copybit PORTB, 2, PORTA, 0x18 ; B data - copybiti PORTB, 1, TRISA, 0x20 ; A enable - copybiti PORTB, 1, TRISE, 0x01 ; A enable - copybit PORTB, 0, PORTA, 0x20 ; A data - copybit PORTB, 0, PORTE, 0x01 ; A data - - copybiti PORTA, 6, PORTD, 0x10 ; D - copybiti PORTC, 0, PORTC, 0x80 ; E - copybiti PORTC, 1, PORTC, 0x40 ; F - copybiti PORTC, 2, PORTC, 0x20 ; G - ; 12 x copybit @6 = 48cy - - decfsz COUNTINNER, 1, 0 ; 1 cycle - goto delayinner_loop ; 2 cycles (skipped or not) -; exited delayinner_loop ; total: 51cy * 256 = 13056cy + bsf COUNTSLOW, SLOWEXP, 0 +delayslow_loop + +delaymedium_loop + +delayfast_loop + decfsz COUNTFAST, 1, 0 ; 1 cycle + goto delayfast_loop ; 2 cycles (skipped or not) +; exited delayfast_loop ; total: 3 * 256 = 768 cycles + + + decfsz COUNTMEDIUM, 1, 0 ; 1 cycle + goto delaymedium_loop ; 2 cycles (skipped or not) +; exited delaymedium_loop ; total: ~198000 cycles ; each cycle 0.2us - ; so each inner loop is ~2.6ms + ; so each medium loop is ~40ms - decfsz COUNTOUTER, 1, 0 - goto delayouter_loop -; exited delayouter_loop + decfsz COUNTSLOW, 1, 0 + goto delayslow_loop +; exited delayslow_loop - goto loop + return end diff --git a/pcb/Makefile b/pcb/Makefile index 574a0d8..76d4555 100644 --- a/pcb/Makefile +++ b/pcb/Makefile @@ -27,7 +27,7 @@ o=>$@.new && mv -f $@.new $@ CIRCUITPARTS= control.partlist circuit.partlist BULKRESPARTS= bulkres-select.partlist bulkres-items.partlist -picprogs: flasher.hex flash-all.hex +picprogs: flasher.hex netlists: reversers.net detectors.net \ reversers.hole-rep detectors.hole-rep \ diff --git a/pic.make b/pic.make index 574a0d8..76d4555 100644 --- a/pic.make +++ b/pic.make @@ -27,7 +27,7 @@ o=>$@.new && mv -f $@.new $@ CIRCUITPARTS= control.partlist circuit.partlist BULKRESPARTS= bulkres-select.partlist bulkres-items.partlist -picprogs: flasher.hex flash-all.hex +picprogs: flasher.hex netlists: reversers.net detectors.net \ reversers.hole-rep detectors.hole-rep \ diff --git a/spice/Makefile b/spice/Makefile index 574a0d8..76d4555 100644 --- a/spice/Makefile +++ b/spice/Makefile @@ -27,7 +27,7 @@ o=>$@.new && mv -f $@.new $@ CIRCUITPARTS= control.partlist circuit.partlist BULKRESPARTS= bulkres-select.partlist bulkres-items.partlist -picprogs: flasher.hex flash-all.hex +picprogs: flasher.hex netlists: reversers.net detectors.net \ reversers.hole-rep detectors.hole-rep \