Well there's a few mistake in your code anyways...
First, you check for a High level for your push-button... fine, but you enable the internal pull-up... thus this 'should' always consider that there's one push button pressed.
Next, you never loop in your code.. there's on missing GOTO LOOP.. this results in stack underflow.
Assuming your push button are connected between, gnd and the I/O and GND, using the internal weak-pull-ups, i would bet the following will work
I may feel some incoming timing problem(s)Code:@ DEVICE PIC12F675, XT_OSC @ DEVICE pic12F675, WDT_ON @ DEVICE pic12F675, PWRT_ON @ DEVICE pic12F675, MCLR_OFF @ DEVICE pic12F675, BOD_ON DEFINE OSC 3 TRISIO.0 = 0 ' set GPIO.0 as output TRISIO.1 = 1 ' set GPIO.0 as input TRISIO.2 = 1 ' set GPIO.0 as input CMCON = 7 ' turn off analog comparator ADCON0.0 = 0 ADCON0.1 = 0 ADCON0.2 = 0 OPTION_REG.7 = 0 VRCON = 0 ANSEL = 0 '// Setup IR bit widths / carrier cycle times Header CON 96 '// Header = (96 * 25uS) = 2.4mS burst Zero CON 24 '// Zero = (24 * 25uS) = 0.6mS burst One CON 48 '// One = (48 * 25uS) = 1.2mS burst '// Define variables Cycles VAR BYTE BANK0 '// Holds number of 40KHz carrier cycles i var byte Loop: if gpio.1 = 0 then cycles = header gosub pulse cycles = zero gosub dark cycles = zero gosub pulse cycles = zero gosub dark endif if gpio.2 = 0 then cycles = header gosub pulse cycles = zero gosub dark cycles = one gosub pulse endif GOTO LOOP Pulse: '// Emits # of 38.461 kHz bursts held in variable Cycles for i = 1 to cycles ASM ;// with auto delay between bursts ;bsf GPIO, 0 ;// 1uS, LED=on [need 25uS total MOVE?CT 1, GPIO,0 goto $+1 ;// 3uS (2uS per goto $+1) goto $+1 ;// 5uS goto $+1 ;// 7uS goto $+1 ;// 9uS goto $+1 ;// 11uS goto $+1 ;// 13uS bcf GPIO, 0 ;// 14uS, LED=off decfsz _Cycles,F ;// 24uS goto $+1 ;// 16uS goto $+1 ;// 18uS goto $+1 ;// 20uS goto $+1 ;// 22uS ENDASM next i return Dark: for i = 1 to cycles ASM ;// with auto delay between bursts ;bcf GPIO, 0 ;// 1uS, LED=on [need 25uS total MOVE?CT 0,GPIO,0 goto $+1 ;// 3uS (2uS per goto $+1) goto $+1 ;// 5uS goto $+1 ;// 7uS goto $+1 ;// 9uS goto $+1 ;// 11uS goto $+1 ;// 13uS goto $+1 ;// 13uS goto $+1 ;// 13uS goto $+1 ;// 16uS goto $+1 ;// 18uS goto $+1 ;// 20uS goto $+1 ;// 20uS ENDASM next i return




Bookmarks