; Strobe Experiment ; Low duty cycle lighting. ; INCLUDE "P12F509.INC" INCLUDE "macross12f509.inc" ; Self running, no watchdog... __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC ; available file registers 0x7-0x1f (25 registers) ; (there are more at 0x30-0x3f but only by ; FSR indirect addressing.) CBLOCK 0x07 t1,t2,t3 pix CBLOCK07 ; last ENDC IF CBLOCK07 > 20 ERROR "CBLOCK07 exceeded" ENDIF ORG 0 GOTO Start Slow: DECFSZ t1,f GOTO Slow DECFSZ t2,f GOTO Slow DECFSZ t3,f GOTO Slow RETURN DELAY MACRO time MOVLF ((time >> 0) & 0xff) + 1,t1 MOVLF ((time >> 8) & 0xff) + 1,t2 MOVLF ((time >> 16) & 0xff) + 1,t3 CALL Slow ENDM Start: ; All five outputs to "out" ; GPIO 3 can only be "in" MOVLW 0 TRIS GPIO MOVLW b'11011111' ; 0xDF, internal timer, no pullups, slowest watchdog OPTION MOVLF 0xAA,pix Ere: MOVFF pix,GPIO ; Oscillator runs at 4mhz ; Instructions take 4 cycles each ; Delay loop uses ~3 instructions/tick ; ; So, Delay time for X fps is 1000000 / (3 * X) R EQU 10904 ;T EQU 21808 ; total count for 15fps ;T EQU 13889 ; 24 fps T EQU 1000000/(3 * 28) Ton EQU T/8 Toff EQU T - Ton A: MOVLF 0xff,GPIO DELAY Ton MOVLF 0,GPIO DELAY Toff GOTO A MOVLF ((R >> 0) & 0xff) + 1,t1 MOVLF ((R >> 8) & 0xff) + 1,t2 MOVLF ((R >> 16) & 0xff) + 1,t3 CALL Slow INCF pix,f GOTO Ere GOTO Ere END