There are probably a gozillion various ways to do this, but since you're already using GP2, and this pin is the Timer0 clock input, maybe something like this?
Code:' // Internal RC OSC, WDT OFF, /MCLR reset function OFF @ DEVICE INTRC_OSC_NOCLKOUT,WDT_OFF,MCLR_OFF DEFINE OSCCAL_1K 1 ' Calibrate internal oscillator GPIO = 0 ' All outputs to 0 TRISIO = %00000100 ' GPIO.2/T0CKI = input, rest outputs CMCON = 7 ' Comparators OFF, all digital ' // Pull-ups on, TMR0 clock source = GP2/T0CKI input ' // Increment TMR0 on high-to-low transitions on GP2/T0CKI ' // Assign prescaler to WDT for 1:1 clocks on GP2/T0CKI OPTION_REG = %00111000 ' // Pre-load timer0 to over-flow on 3rd pulse on GP2/T0CKI TMR0 = 253 ' 1st clk = 254, 2nd = 255, 3rd = over-flow & int ' // Enable global, peripheral & timer0 interrupts INTCON = %11100000 On Interrupt Goto FireFlash Main: @ NOP GOTO Main DISABLE FireFlash: HIGH GPIO.4 ' Fire flash PAUSEUS 500 ' Adjust for time you need to fire flash here LOW GPIO.4 TMR0 = 253 ' Reload for 3rd pulse to trigger int INTCON.2 = 0' Reset TMR0 int flag before leaving RESUME ' Re-enable interrupts & return ENABLE END




Bookmarks