; ; isp2.asm Timing control program for 12C509 in H8 ISP2 Adapter ; Copyricht(C)2000 By H.Kashima ; ; pin allocation ; GP0(7) out Vpp switch(Lo:12V, Hi:5V) ; GP1(6) out H8RESET(Hi: RESET) ; GP3(4) in PROGRAM SWITCH(Lo: ON) ; GP4(3) out PROGRAM LED(Lo: ON) ; GP5(2) out POWER LED(Lo: ON) ; ; list p=12c509a #include __CONFIG _CP_OFF & _WDT_OFF & _MCLRE_OFF & _IntRC_OSC cblock 0x07 PTIME, WTIME, PROGSW endc #define GP0_VPP 0 #define GP1_H8RES 1 #define GP3_PROGSW 3 #define GP4_PROGLED 4 #define GP5_PWRLED 5 ORG 0x000 ; ; initialize ; movwf OSCCAL ; update register with factory cal value movlw b'11011100' movwf GPIO movlw b'11010111' ; TMR0 src internal, TMR0 1/256 option movlw b'11001100' tris GPIO ; ; main loop ; main clrf PROGSW swon1 btfss GPIO, GP3_PROGSW ; push down SW? goto swon1b goto swon1 swon1b movlw 3 ; wait 30ms call w10ms btfsc GPIO, GP3_PROGSW ; recheck goto swon1 swon2 btfsc GPIO, GP3_PROGSW ; release SW? goto swon2b goto swon2 swon2b movlw 3 ; wait 30ms call w10ms btfss GPIO, GP3_PROGSW ; recheck goto swon2 bsf GPIO, GP1_H8RES ; H8RESET goes high ; (redirected to /RESET via inverter) movlw 1 ; wait 10ms call w10ms btfsc PROGSW, 0 goto alt_off alt_on bsf GPIO, GP0_VPP ; Vpp goes +12V bsf PROGSW, 0 bcf GPIO, GP4_PROGLED ; PROG LED turn ON goto w10 alt_off bcf GPIO, GP0_VPP ; Vpp goes +5V bcf PROGSW, 0 bsf GPIO, GP4_PROGLED ; PROG LED turn OFF w10 movlw 1 ; wait 10ms call w10ms bcf GPIO, GP1_H8RES ; H8RESET goes low goto swon1 ; ; wait W * 10ms ; w10ms movwf WTIME wloop2 clrf TMR0 wloop1 movlw 29 subwf TMR0, W ; wait 10ms btfss STATUS, Z goto wloop1 decfsz WTIME, F goto wloop2 retlw 0 END ; directive 'end of program'