; file: buttontest.asm ; ; test input on gpio3. ; INCLUDE "P12F509.INC" INCLUDE "macross12f509.inc" ; chip-level options: all easiest! __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _IntRC_OSC LEDSOFFVALUE EQU 0x37 LEDSONVALUE EQU LEDSOFFVALUE ^ 0x37 LEDS ; available file registers 0x7-0x1f (25 registers) ; (there are more at 0x30-0x3f but only by ; FSR indirect addressing.) CBLOCK 0x07 ; keep dn first, for timing update with cb30's d0,d1,d2,d3 ; for various timing and misc t ; the smallest temp, used by macros rnd ; for randomizer p0,p1,p2 ; for patterns bitsOut led0:2 ; 1st: linear brightness, 2nd: running sum, 3rd: target brightness led0Target led1:2 led1Target led2:2 led2Target led3:2 led3Target led4:2 led4Target cblock07End ; keep this last ENDC IF cblock07End > 0x20 ERROR "CBLOCK07 exceeded" ENDIF CBLOCK 0x30 ; Three inputs to delay loops, lo med hi parts of loop. i_t0 i_t1 i_t2 i_X i_Y i_Z cblock30End ; keep this last ENDC IF cblock30End > 0x40 ERROR "CBLOCK30 exceeded" ENDIF ; MACROS ORG 0 ; lets begin ; we keep a matching jump table at 0x000 and 0x200, ; for certain key routines that we want to "just work" ;GOTOHILO Start GOTO Start ; -------------- ; Other Low Jumps GlideLeds1000: GOTO GlideLeds1000_Impl ; ---------------------------------- ; UTILITIES INCLUDE "utils.inc" ; ---------------------------------- ; MAIN Start: IFBS STATUS,GPWUF GOTO Wakeup ; All five outputs to "out" ; GPIO 3 can only be "in" MOVLW b'00001000' TRIS GPIO MOVLW b'00011111' ; OPTION CALLHILO PowerupDisplay GOTO Sunrise Wakeup: NOP Sunrise: ; all dark CLRF led0 CLRF led1 CLRF led2 CLRF led3 CLRF led4 CLRF led0Target CLRF led1Target CLRF led2Target CLRF led3Target CLRF led4Target MOVLI16 1000,i_t1 CALL GlideLeds256 MOVLI16 500,i_t1 CALL HoldLeds256 MOVLF 0xff,led0Target CALL GlideLeds1000 MOVLF 0x80,led1Target MOVLF 0xc0,led0Target CALL GlideLeds1000 MOVLF 0xff,led1Target MOVLF 0x20,led2Target ; sun begins MOVLF 0x30,led0Target CALL GlideLeds1000 MOVLF 0xff,led1Target MOVLF 0x20,led2Target ; sun begins MOVLF 0x30,led0Target CALL GlideLeds1000 GOTO Sunrise GlideLeds1000_Impl: MOVLI16 1000,i_t1 GOTO GlideLeds256 ; ----------------------------- ; High Code ; ; Code up here in the second page keeps ; STATUS:PA0 high (bit 9, the 512). When ; we branch low, we clear it. ; ; Lastly, we keep an identical jump table in the ; beginning of the page, so GOTO 0 means start ; from anywhere, and GOTO 3 means goto the ; first jump table entry (from either page) and ; so forth. ORG 0x200 GOTO Start END ; EOF