; ; isp.asm Timing control program for 12C508(672) in H8 ISP Adapter ; Copyricht(C)1999 By H.Kashima ; ; pin allocation ; GP0(7) out Vpp switch(Lo:12V, Hi:5V) ;(C672) GP0(7) in ADC input for Vpp arbitation ; GP1(6) out H8RESET(Lo: RESET) ; GP2(5) in TxD ; GP3(4) in PROGRAM SWITCH(Lo: ON) ; GP4(3) out PROGRAM LED(Lo: ON) ; GP5(2) out POWER LED(Lo: ON) ; ; comment out if 12C508 ; ;#define P12C672JW ifdef P12C672JW list p=12c672 #include else list p=12c508 #include endif ifdef P12C672JW __CONFIG _CP_OFF & _WDT_OFF & _MCLRE_OFF & _INTRC_OSC else __CONFIG _CP_OFF & _WDT_OFF & _MCLRE_OFF & _IntRC_OSC endif ifdef P12C672JW cblock 0x20 PTIME, WTIME, PROGSW endc else cblock 0x07 PTIME, WTIME, PROGSW endc endif #define GP0_VPP 0 #define GP1_H8RES 1 #define GP2_TXD 2 #define GP3_PROGSW 3 #define GP4_PROGLED 4 #define GP5_PWRLED 5 ORG 0x000 ; ; initialize ; ifdef P12C672JW bsf STATUS, RP0 movwf OSCCAL bcf STATUS, RP0 else movwf OSCCAL ; update register with factory cal value endif endif movlw b'11011110' movwf GPIO ifdef P12C672JW bsf STATUS, RP0 movlw b'11010111' movwf OPTION_REG movlw b'11001110' movwf TRISIO movlw b'00000111' movwf ADCON1 bcf STATUS, RP0 else movlw b'11010111' option movlw b'11001110' tris GPIO endif ; ; 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 bcf GPIO, GP1_H8RES ; H8RESET goes low movlw b'11001100' ; GP1 = output ifdef P12C672JW bsf STATUS, RP0 movwf TRISIO bcf STATUS, RP0 else tris GPIO endif 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 movlw b'11001110' ; GP1 = Hi-Z ifdef P12C672JW ; H8RESET goes high-Z bsf STATUS, RP0 movwf TRISIO bcf STATUS, RP0 else tris GPIO endif bsf GPIO, GP1_H8RES goto swon1 ; ; wait W * 10ms ; w10ms movwf WTIME wloop2 movfw TMR0 movwf PTIME ; save TMR0 wloop1 movfw PTIME subwf TMR0, W sublw 39 ; wait 10ms btfss STATUS, Z goto wloop1 decfsz WTIME, F goto wloop2 return END ; directive 'end of program'