From: ian Date: Mon, 9 Aug 2004 01:45:12 +0000 (+0000) Subject: supposedly good program X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=109bbe13f57cf5e82ab6c3ae34a882f1aa507090;p=trains.git supposedly good program --- diff --git a/iwjpictest/copybits.asm b/iwjpictest/copybits.asm index 45e7b82..c456458 100644 --- a/iwjpictest/copybits.asm +++ b/iwjpictest/copybits.asm @@ -1,13 +1,63 @@ ; -; __config config + include /usr/share/gputils/header/p18f458.inc - db 0x00 +; __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 -__config - db 0x00, 0x15, 0x00, 0x00 - db 0x00, 0x00, 0x85, 0x00 - db 0x0f, 0xc0, 0x0f, 0xe0 - db 0x0f, 0x40 +ACCSFR equ 0x0f00 - end +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-ACCSFR, 0, 0 +loop + btg LATA-ACCSFR, 0, 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 45e7b82..c456458 100644 --- a/iwjpictest/flasher.asm +++ b/iwjpictest/flasher.asm @@ -1,13 +1,63 @@ ; -; __config config + include /usr/share/gputils/header/p18f458.inc - db 0x00 +; __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 -__config - db 0x00, 0x15, 0x00, 0x00 - db 0x00, 0x00, 0x85, 0x00 - db 0x0f, 0xc0, 0x0f, 0xe0 - db 0x0f, 0x40 +ACCSFR equ 0x0f00 - end +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-ACCSFR, 0, 0 +loop + btg LATA-ACCSFR, 0, 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/serialloop.asm b/iwjpictest/serialloop.asm index 45e7b82..c456458 100644 --- a/iwjpictest/serialloop.asm +++ b/iwjpictest/serialloop.asm @@ -1,13 +1,63 @@ ; -; __config config + include /usr/share/gputils/header/p18f458.inc - db 0x00 +; __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 -__config - db 0x00, 0x15, 0x00, 0x00 - db 0x00, 0x00, 0x85, 0x00 - db 0x0f, 0xc0, 0x0f, 0xe0 - db 0x0f, 0x40 +ACCSFR equ 0x0f00 - end +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-ACCSFR, 0, 0 +loop + btg LATA-ACCSFR, 0, 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